updateText = (updateAll || type == CellAttribute.TEXT),
updateStyle = (updateAll || type == CellAttribute.STYLE),
updateSize = (updateAll || type == CellAttribute.SIZE),
updateMerge = (updateAll || type == CellAttribute.MERGE);
Cell cell = Utils.getCell(sheet, row, col);
JSONObject attrs = new JSONObject();
//row num, cell num attr
// if (cell != null) {
// attrs.put("r", row);
// attrs.put("c", col);
// }
//merge
MergeIndex mergeIndex = mergeAggregation.add(row, col);
if (updateMerge && mergeIndex != null) {
attrs.put("mi", mergeIndex.getMergeId());
attrs.put("mc", mergeIndex.getMergeCSSId());
}
//width, height id
if (updateSize) {
if (cell != null) {
//process overflow when cell type is string, halign is left, no wrap, no merge
CellStyle cellStyle = cell.getCellStyle();
if (cell.getCellType() == Cell.CELL_TYPE_STRING &&
mergeIndex == null && !cellStyle.getWrapText() &&
BookHelper.getRealAlignment(cell) == CellStyle.ALIGN_LEFT) {
attrs.put("ovf", 1); //1 stand for true
int c = getMaxOverflowableCellIndex(cell, sheet.getRow(row));
if (c != col) {
attrs.put("moc", c);
}
}
}
}
//style attr
if (updateStyle) {
CellFormatHelper cfh = new CellFormatHelper(sheet, row, col, getMergeMatrixHelper(sheet));
String style = cfh.getHtmlStyle();
if (!Strings.isEmpty(style)) {
int idx = styleAggregation.add(style);
attrs.put("s", idx);
}
String innerStyle = cfh.getInnerHtmlStyle();
if (!Strings.isEmpty(innerStyle)) {
int idx = styleAggregation.add(innerStyle);
attrs.put("is", idx);
}
if (cfh.hasRightBorder()) {
attrs.put("rb", 1);
}
}
if (cell != null) {
int cellType = cell.getCellType();
if (cellType != Cell.CELL_TYPE_BLANK)
attrs.put("ct", cellType);
if (updateText) {
if (cellType != Cell.CELL_TYPE_BLANK) {
final String cellText = getCelltext(sheet, row, col);
final String editText = getEdittext(sheet, row, col);
final String formatText = getCellFormatText(sheet, row, col);
if (Objects.equals(cellText, editText) && Objects.equals(editText, formatText)) {
attrs.put("meft", textAggregation.add(cellText));
} else {
attrs.put("t", textAggregation.add(cellText));
attrs.put("et", textAggregation.add(editText));
attrs.put("ft", textAggregation.add(formatText));
}
}
}
if (updateStyle) {
CellStyle cellStyle = cell.getCellStyle();
boolean locked = cellStyle.getLocked();
if (!locked)
attrs.put("l", "f"); //f stand for "false"
boolean wrap = cellStyle.getWrapText();