Same Apache poi (excel) code acting differently depending on system types (32bit, 64bit)

…衆ロ難τιáo~ 提交于 2020-01-17 05:04:33

问题


I have successfully generated an excel file using apache poi 3.10, the program only runs as expected on 32bit systems.

BUT when tried to run it on 64bit systems, most of the cells data are left out, they simply don't show up (but the same code will work just fine on 32bit systems). what can I do so that all the generated cell data can show even on 64bit systems?

HSSFWorkbook my_xls_workbook = new HSSFWorkbook(input_document);
HSSFSheet my_worksheet = my_xls_workbook.getSheetAt(0);

Cell cell = null;
cell = my_worksheet.getRow(0).getCell(10);
cell.setCellValue(nme.getText());                              
cell = my_worksheet.getRow(3).getCell(6);
cell.setCellValue(frm.getText);
cell = my_worksheet.getRow(4).getCell(3);
cell.setCellValue(empid);

//Closing InputStream
input_document.close();

FileOutputStream output_file =new FileOutputStream(new File("C:PayslipG.xls"));

//write data
my_xls_workbook.write(output_file);
//closing stream
output_file.close();

Thanks!


回答1:


Promoting some comments to an answer - Java should be platform and architecture agnostic. Unless you're doing platform-specific code, eg AWT or Swing, there shouldn't be any differences between runtime platforms

The one thing the can differ between machines, however, is the classpath. Make sure you really have the same code and the same jars on both machines!

A sadly common problem is for runtimes, frameworks etc to silently bundle outdated copies of Apache POI without telling you. If you make use of the code included in the Apache POI FAQ Entry, you can check which POI jars you are really using at runtime.

As per the comments, those jars aren't the ones you think you are using. As per this other POI FAQ, mixing POI jars between versions isn't supported. Remove the older POI jars as identified, so you only use the latest ones, and your code will behave correctly



来源:https://stackoverflow.com/questions/33790512/same-apache-poi-excel-code-acting-differently-depending-on-system-types-32bit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!