-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlin
More file actions
44 lines (42 loc) · 1.85 KB
/
lin
File metadata and controls
44 lines (42 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
JsonArray jsonRow = new JsonArray();
for (int colIdx = first; colIdx < last; colIdx++) {
Cell cell = row.getCell(colIdx);
if (cell != null) {
Object value = XDDFChartUtils.getCellValue(cell);
Pair<Integer, Integer> key = Pair.of(rowIdx, colIdx);
JsonObject jsonCell = new JsonObject();
jsonCell.addProperty("text", value.toString());
jsonCell.addProperty("row", rowIdx);
jsonCell.addProperty("column", colIdx);
CellRangeAddress m = merged.getOrDefault(key, null);
if (m != null) {
int r = m.getLastRow();
int c = m.getLastColumn();
jsonCell.addProperty("rowSpan", r - rowIdx + 1);
jsonCell.addProperty("colSpan", c - colIdx + 1);
}
jsonRow.add(jsonCell);
}
}
if (jsonRow.size() > 0) {
jsonTable.add(jsonRow);
}
}
if (jsonTable.size() == 0) {
return;
}
// correct the index
logger.info("table");
final int minCol = minColx;
int minRow = jsonTable.get(0).getAsJsonArray().get(0).getAsJsonObject().get("row").getAsInt();
jsonTable.forEach((row) -> {
row.getAsJsonArray().forEach(cell -> {
JsonObject jsonObject = cell.getAsJsonObject();
int r = jsonObject.get("row").getAsInt();
int c = jsonObject.get("column").getAsInt();
jsonObject.addProperty("row", r - minRow);
jsonObject.addProperty("column", c - minCol);
logger.info("{}", jsonObject);
});
logger.info("");
});