英文:
error comes like this Invalid row number (65536) outside allowable range (0..65535) while im using .xlxs format
问题
我尝试了3种格式,.xls、.xlxs、.xls。
我的目标是从查询中获取值,并将输出显示为xls文件。
我的代码是:
filename = "file.xlxs";
workbook = new HSSFWorkbook()
sheet1 = workbook.createSheet("All Files");
rs=stmt.executeQuery("select slno from files");
while (rs.next()){
i++;
HSSFRow row = sheet1.createRow((int)y);
cell = row.createCell((short)0);
cell.setCellValue(rs.getString("slno"));
cell.setCellStyle(cellStyle);
}
我遇到了以下错误:
java.lang.IllegalArgumentException: Invalid row number (65536) outside allowable range (0..65535)
我的查询中的 slno 包含超过 96000 个数字。
英文:
i'm tried 3 type of formats .xls,.xlxs,.xls.
my aim is getting a values from the query and display output as a xls file.
my code is :
filename = "file.xlxs";
workbook = new HSSFWorkbook()
sheet1 = workbook.createSheet("All Files");
rs=stmt.executeQuery("select slno from files");
while (rs.next()){
i++;
HSSFRow row = sheet1.createRow((int)y);
cell = row.createCell((short)0);
cell.setCellValue(rs.getString("slno"));
cell.setCellStyle(cellStyle);
}
i'm getting error like this:
java.lang.IllegalArgumentException: Invalid row number (65536) outside allowable range (0..65535)
my query slno have contain above 96000 numbers
答案1
得分: 2
文件命名为.xlxs
并不改变HSSFWorkbook
实际上使用了.xls
文件的格式。
如果你想要写一个.xlsx
(而不是.xlxs
)文件,该格式没有行数限制,使用XSSFWorkbook
。
就像文档所说:
> HSSF是POI项目对Excel '97(-2007)文件格式的纯Java实现。XSSF是POI项目对Excel 2007 OOXML (.xlsx) 文件格式的纯Java实现。
英文:
Naming the file .xlxs
doesn't change the fact that HSSFWorkbook
uses the format of .xls
files.
If you wanted to write an .xlsx
(not .xlxs
) file, which doesn't have that row count restriction, use XSSFWorkbook
.
Just like the documentation says:
> HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论