apache-poi

POI cannot open a workbook that opens in Excel

可紊 提交于 2019-12-19 12:05:34
问题 When I try to open a .xlsx file in POI, I get an exception: java.lang.IllegalArgumentException: The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. Is it really an excel file? at org.apache.poi.hssf.usermodel.HSSFWorkbook.getWorkbookDirEntryName(HSSFWorkbook.java:223) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:245) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:188) I notice that the code is considering it a .xls file

Java POI Excel creating new column and new rows

核能气质少年 提交于 2019-12-19 11:33:25
问题 Ok so Im iterating over a list and instead of inserting values into cells horizontally, im putting the values in the cells vertically. It works fine for the first time through the list but when I go in the list the 2nd time it blows away the first list and replaces it in the 2nd column. if i remove the row= 0 at the end of the loop, it look like: val 1 val 2 val 1 val 2 ========= int row = 0; int k = 1; for (List dataList: someList) { Row myRow = sheet.createRow ((short)row); myRow.createCell

Java POI Excel creating new column and new rows

拈花ヽ惹草 提交于 2019-12-19 11:33:12
问题 Ok so Im iterating over a list and instead of inserting values into cells horizontally, im putting the values in the cells vertically. It works fine for the first time through the list but when I go in the list the 2nd time it blows away the first list and replaces it in the 2nd column. if i remove the row= 0 at the end of the loop, it look like: val 1 val 2 val 1 val 2 ========= int row = 0; int k = 1; for (List dataList: someList) { Row myRow = sheet.createRow ((short)row); myRow.createCell

How to set heading style for a paragraph in a docx file using Apache POI? [duplicate]

可紊 提交于 2019-12-19 11:02:10
问题 This question already has answers here : How can I use predefined formats in DOCX with POI? (4 answers) Closed last year . I am trying to create a docx file with poi but I cannot set heading style for a paragraph. XWPFDocument document= new XWPFDocument(); //Write the Document in file system FileOutputStream out = new FileOutputStream(new File("C:/Users/2/Desktop/RequirementModelDocument.docx")); XWPFParagraph paragraph = document.createParagraph(); XWPFRun run=paragraph.createRun();

I need Apache POI Pictures converted from a word document to a html file

陌路散爱 提交于 2019-12-19 11:00:17
问题 I have some code that uses the Java Apache POI library to open a Microsoft word document and convert it to html, using the the Apache POI and it also gets the byte array data of images on the document. But I need to convert this information to html to write out to an html file. Any hints or suggestions would be appreciated. Keep in mind that I am a desktop dev developer and not a web programmer, so when you make suggestions, please remember that. The code below gets the image. private void

Exception occurs while opening .xlsx file using Apache POI

无人久伴 提交于 2019-12-19 10:11:23
问题 I have been working on an android application in which i have to open .xls and .xlsx file for further implementation. In case of .xls everything is working fine but when i try to open .xls x file it gives me exception. below is my code Please help me solving these exception @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_code && resultCode == RESULT_OK && null != data) {

Exception occurs while opening .xlsx file using Apache POI

你说的曾经没有我的故事 提交于 2019-12-19 10:11:13
问题 I have been working on an android application in which i have to open .xls and .xlsx file for further implementation. In case of .xls everything is working fine but when i try to open .xls x file it gives me exception. below is my code Please help me solving these exception @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_code && resultCode == RESULT_OK && null != data) {

Problem running official examples LineChars and ScatterChart with Apache POI 4.0

时间秒杀一切 提交于 2019-12-19 09:42:09
问题 There's a problem with the official examples LineChart and ScatterChart for Apache POI 4.0. They compile and run without errors, but the created Excel file cannot be opened stating that there is unreadable content. Excel 2010 & 2016 are giving the option to recover data from the workbook and after clickin' yes, this dialog appears. What might be the problem? 回答1: The new XDDF code lacks the setting the axId s in the lineChart and scatterChart . In /xl/charts/chart1.xml this looks like: <c

How to delete blank rows in between the sheet using POI?

梦想的初衷 提交于 2019-12-19 09:17:35
问题 I want to delete blank row from Excel sheet using POI. We have method like shiftRow() or removeRow() but its not for use in this case. Please help me to get it done. 回答1: Please try following piece of code. It works for me as well when more than one consecutive blank rows existing. for(int i = 0; i < sheet.getLastRowNum(); i++){ if(sheet.getRow(i)==null){ isRowEmpty=true; sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1); i--; continue; } for(int j =0; j<sheet.getRow(i).getLastCellNum();j++){

How to get the formatted value of a number for a cell in Apache POI?

荒凉一梦 提交于 2019-12-19 09:04:34
问题 I wanted to get the value of a Numeric cell as a simple string. Suppose there the type of cell is numeric with value 90% . Now I cannot use cell.getStringCellValue() as it will throw exception. I also cannot use cell.getNumericCellValue() as it will return me .9 and not 90% . I want to store in db which is of type varchar2, so I want the value in string only. I cannot change the cell type in xls as its the end user job, I have to handle this in code itself. Also formatter does't work well as