Indra Yadav
Indra Yadav

Reputation: 600

How to convert HSSFWorkbook object into XSSFWorkbook?

I am using Spring 3 AbstractExcelView to use export - to - excel functionality to download file into .xls format but when my rows are greater than 65536, it throws an exception:

Invalid row number (65536) outside allowable range (0..65535)

I want to use XSSFworkbook to create .xlsx file but the method of AbstractExcelView which I have overridden,

protected void buildExcelDocument(Map<String, Object> model,
            HSSFWorkbook wb, HttpServletRequest request,
            HttpServletResponse response) throws Exception {}

only takes HSSFWorkbook as an argument which I want to convert into XSSFWorkbook object to create .xlsx format file.

Upvotes: 2

Views: 6072

Answers (2)

Gagravarr
Gagravarr

Reputation: 48356

The Apache POI guide to converting existing HSSF Usermodel code to SS Usermodel (for XSSF and HSSF) covers the very case you're asking about

It's possible, with a fairly small amount of work, to convert you code so that it works transparently for both HSSF (.xls) and XSSF (.xlsx) via the new common interfaces.

For your specific case, it looks like you'll need to get the sourcecode for your spring module, convert that as described in the guide, then contribute back a patch.

Upvotes: 2

centic
centic

Reputation: 15882

it seems this is not yet possible, see the improvement request at https://jira.springsource.org/browse/SPR-6898 which is not yet fixed...

Upvotes: 1

Related Questions