error comes like this Invalid row number (65536) outside allowable range (0..65535) while im using .xlxs format

huangapple go评论75阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年9月4日 16:16:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/63737374.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定