-2

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

ThieveKan
  • 1
  • 1
  • 3

1 Answers1

2

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.

Andreas
  • 154,647
  • 11
  • 152
  • 247