应付配置文件导入保存该文件
This commit is contained in:
@@ -33,16 +33,20 @@ public class ExcelGrid
|
||||
/** 合并区域左上角横向占几列,其余单元格为 0 */
|
||||
private final int[][] colSpan;
|
||||
|
||||
/** 纵向合并时,被盖住的格子指向左上角行;没有纵向合并是 -1 */
|
||||
private final int[][] rowAnchor;
|
||||
|
||||
private final int rows;
|
||||
|
||||
private final int cols;
|
||||
|
||||
private ExcelGrid(String[][] text, Double[][] number, String[][] linkSheet, int[][] colSpan, int rows, int cols)
|
||||
private ExcelGrid(String[][] text, Double[][] number, String[][] linkSheet, int[][] colSpan, int[][] rowAnchor, int rows, int cols)
|
||||
{
|
||||
this.text = text;
|
||||
this.number = number;
|
||||
this.linkSheet = linkSheet;
|
||||
this.colSpan = colSpan;
|
||||
this.rowAnchor = rowAnchor;
|
||||
this.rows = rows;
|
||||
this.cols = cols;
|
||||
}
|
||||
@@ -88,6 +92,14 @@ public class ExcelGrid
|
||||
Double[][] number = new Double[Math.max(rows, 0)][Math.max(cols, 0)];
|
||||
String[][] linkSheet = new String[Math.max(rows, 0)][Math.max(cols, 0)];
|
||||
int[][] colSpan = new int[Math.max(rows, 0)][Math.max(cols, 0)];
|
||||
int[][] rowAnchor = new int[Math.max(rows, 0)][Math.max(cols, 0)];
|
||||
for (int r = 0; r < rowAnchor.length; r++)
|
||||
{
|
||||
for (int c = 0; c < rowAnchor[r].length; c++)
|
||||
{
|
||||
rowAnchor[r][c] = -1;
|
||||
}
|
||||
}
|
||||
if (sheet != null && rows > 0 && cols > 0)
|
||||
{
|
||||
for (int r = 0; r < rows; r++)
|
||||
@@ -115,9 +127,21 @@ public class ExcelGrid
|
||||
{
|
||||
colSpan[r0][c0] = width;
|
||||
}
|
||||
int bottom = Math.min(region.getLastRow(), rows - 1);
|
||||
int right = Math.min(region.getLastColumn(), cols - 1);
|
||||
if (bottom > r0)
|
||||
{
|
||||
for (int r = r0 + 1; r <= bottom; r++)
|
||||
{
|
||||
for (int c = c0; c <= right; c++)
|
||||
{
|
||||
rowAnchor[r][c] = r0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ExcelGrid(text, number, linkSheet, colSpan, rows, cols);
|
||||
return new ExcelGrid(text, number, linkSheet, colSpan, rowAnchor, rows, cols);
|
||||
}
|
||||
|
||||
public int rows()
|
||||
@@ -139,6 +163,18 @@ public class ExcelGrid
|
||||
return text[row][col] == null ? "" : text[row][col];
|
||||
}
|
||||
|
||||
/** 本格有字就用本格。纵向合并盖住的空格,用合并区左上角的原文。 */
|
||||
public String mergedText(int row, int col)
|
||||
{
|
||||
String own = text(row, col);
|
||||
if (!own.isEmpty() || row < 0 || col < 0 || row >= rows || col >= cols)
|
||||
{
|
||||
return own;
|
||||
}
|
||||
int anchor = rowAnchor[row][col];
|
||||
return anchor < 0 ? "" : text(anchor, col);
|
||||
}
|
||||
|
||||
public Double number(int row, int col)
|
||||
{
|
||||
if (row < 0 || col < 0 || row >= rows || col >= cols)
|
||||
|
||||
Reference in New Issue
Block a user