开发者

JExcel Warning: Could not add cell at A257 because it exceeds the maximum column limit'

I was asked to add an average amount of data from my web-app (basically a List from a SQL) into a downloadable Excel file, so I did a servlet to generate the Excel.

Problem is that jxl API doesn’t seem to like more than 256 rows, and my data is more than a thousand.

Is there any way to go around this limitation? I would like to keep using this API if I could (no need to install different APIs in the server and it’s easy to use). But I will change if I must.

Thanks for all!

PS: he开发者_开发知识库re is the main code of the servlet:

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;


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

should be

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

and so on. It is not the row limit you are facing, but column limit. Check out these javadocs.


I think until recent versions of Excel it doesn't support more than 256 columns. I assume that your library hasn't caught up with the latest release.

If you only need basic XLS generation features, you can actually save a HTML table as a .XLS with associated mime-type, and Excel will open it transparently. I doubt you can do anything like formulae or charts or anything else clever with that approach though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜