新增路线产品

This commit is contained in:
liuminghui
2026-11-06 13:39:26 +08:00
parent b4da248815
commit 6f342d424f
32 changed files with 1850 additions and 785 deletions
@@ -63,6 +63,15 @@ public class ExcelGrid
* 按指定行数上限读取。邮编分区表会超过价卡默认的 2500 行。
*/
public static ExcelGrid read(Sheet sheet, int maxRows)
{
return read(sheet, maxRows, null);
}
/**
* 读取工作表,并在扫描、填值时回报行号。progress 为空时与 {@link #read(Sheet, int)} 相同。
* phase 0 是统计列宽,phase 1 是读取单元格。
*/
public static ExcelGrid read(Sheet sheet, int maxRows, ReadProgress progress)
{
int limit = maxRows < 1 ? MAX_ROWS : maxRows;
int lastRow = sheet == null || sheet.getLastRowNum() < 0 ? -1 : Math.min(sheet.getLastRowNum(), limit - 1);
@@ -85,6 +94,7 @@ public class ExcelGrid
cols = c + 1;
}
}
reportRow(progress, 0, r, lastRow + 1);
}
}
int rows = lastRow + 1;
@@ -113,6 +123,7 @@ public class ExcelGrid
{
fill(row.getCell(c), text, number, linkSheet, r, c);
}
reportRow(progress, 1, r, rows);
}
for (CellRangeAddress region : sheet.getMergedRegions())
{
@@ -144,6 +155,27 @@ public class ExcelGrid
return new ExcelGrid(text, number, linkSheet, colSpan, rowAnchor, rows, cols);
}
/** 读取进度。大约每 20 行回报一次,避免大表回调过密。 */
private static void reportRow(ReadProgress progress, int phase, int row, int total)
{
if (progress == null || total < 1)
{
return;
}
if (row % 20 != 0 && row != total - 1)
{
return;
}
progress.onRow(phase, row, total);
}
/** 工作表读取进度。phase 0 统计列宽,phase 1 读取单元格。 */
@FunctionalInterface
public interface ReadProgress
{
void onRow(int phase, int row, int total);
}
public int rows()
{
return rows;