JExcel Warning: Failed to add cell to A257 because it exceeds the maximum column limit '

I was asked to add the average amount of data from my web application (basically a list from SQL) to the Excel download file, so I made a servlet to create Excel.

The problem is that the jxl API does not seem to be more than 256 lines, and my data is more than a thousand.

Is there a way around this limitation? I would like to continue to use this API if I could (there is no need to install various APIs on the server and its ease of use). But I will change if necessary.

Thanks everyone!

PS: here is the main servlet code:

List<TableProject> sql = (List<TableProject>)session.getAttribute("sql"); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=Export.xls"); w = Workbook.createWorkbook(response.getOutputStream()); s = w.createSheet("Consult Project", 0); for(int i=0;i<sql.size();i++){ s.addCell(new Label(i,0,sql.get(i).getCod_project())); s.addCell(new Label(i,1,sql.get(i).getTxt_project())); s.addCell(new Label(i,2,sql.get(i).getDate_notification())); s.addCell(new Label(i,3,sql.get(i).getDate_last_action())); s.addCell(new Label(i,4,sql.get(i).getTxt_personal())); s.addCell(new Label(i,5,sql.get(i).getTxt_estate())); s.addCell(new Label(i,6,sql.get(i).getTxt_provider())); } w.close(); w = null; 
+4
source share
2 answers
 s.addCell(new Label(i,0,sql.get(i).getCod_project())); 

it should be

 s.addCell(new Label(0, i,sql.get(i).getCod_project())); 

etc. This is not a row constraint that you encounter, but a column constraint. Check out these javadocs .

+4
source

I think that until the latest versions of Excel, it does not support more than 256 columns. I assume that your library did not catch up with the latest version.

If you need only the basic XLS generation functions, you can actually save the HTML table as .XLS with the corresponding mime type, and Excel will open it transparently. I doubt that you can do anything you like, for example, formulas or diagrams or something else smart with this approach.

+1
source

All Articles