我正在使用 POI 3.9 和 SXSSF 创建电子表格。当行数较少时,创建超链接有效。但是,随着大小的增长,处理时间会大大增加并且链接不起作用。它适用于 700 行,但不适用于 70,000。尝试打开文件时,出现此错误:
Excel 在“out.xlsx”中发现无法读取的内容。是否要恢复此工作簿的内容?如果您信任此工作簿的来源,请单击是。
public static void main(String[] args) throws Throwable {
Workbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk
Sheet sh = wb.createSheet();
for(int rownum = 0; rownum < 70000; rownum++){
Row row = sh.createRow(rownum);
for(int cellnum = 0; cellnum < 10; cellnum++){
Cell cell = row.createCell(cellnum);
String address = new CellReference(cell).formatAsString();
cell.setCellValue(address);
if (address.contains("A"))
setHyperlink(cell, address);
}
}
FileOutputStream out = …Run Code Online (Sandbox Code Playgroud)