Im first using JXL to modify one xls file created by POI. After that I will try to read that file with POI. In the moment of POIFSFileSystem creation
poFileSystem = new POIFSFileSystem(input);
Im getting the exception
java.io.IOException: block[ 907 ] already removed - does your POIFS have circular or duplicate block references?
Is this a compatibility problem between those 2 libraries or something else?
Im using POI ver 3.6 and latest version of JXL.
Thanks
changing POIFSFileSystem to NPOIFSFileSystem solved my problem.
Related
I have a problem reading CSV
Dear everybody
I have a CSV with following format in SFTP
Date;Risk 11/01/2020;C4 12/01/2020;C4
I am using Intellij but when I download with java code this File I don't know why receive this content:
Date;Risk 11/01/2020;C4;0,22;N;O;178 12/01/2020;C4;0,22;N;O;178
I think thas is problem for my Intellij when I download file but I don't have any idea why this happened.
I use OpenCSV with version 5.3
List<FieldsCSV> listFieldsCSV = new CsvToBeanBuilder<FieldsCSV>(inStrReader)
.withType(FieldsCSV.class)
.withSeparator(Constants.SEPARATOR_FIELDS)
.withIgnoreQuotations(true)
.withSkipLines(1).build()
.parse();
I am using Apache POI to read and write Excel files for both xls and xlsx formats.
If the code processes folloiwng line for a file written by POI/my code , it doesn't throw an exception but in case of a file written from Excel by user, I get
org.apache.poi.ss.formula.FormulaParseException: Specified named range 'LOCAL_YEAR_FORMAT' does not exist in the current workbook.
The Exception is fired at:
postWB.getSheet(postSheet.getSheetName()).shiftRows(i, postSheet.getPhysicalNumberOfRows(), 1);
As it turns out from some of the questions here, it can be of jar compatibilities or due to bug. I have changed all jars for latest poi library and dependencies.
Any workaround to shiftrows without finding this exception.
I use R XLConnect package.
When I wrote 'XLConnect' function, such as loadWorkbook(), readWorksheetFromFile() etc. , this error message happen.
Error: IllegalArgumentException (Java): Your InputStream was neither
an OLE2 stream, nor an OOXML stream
How to solve this problem?
Before using this function, I took action against crashing between R and Mac OS X by the way http://www.r-bloggers.com/getting-r-and-java-1-8-to-work-together-on-osx/ link told.
I have used Mac OS X.
This message states that the file you have provided to loadWorkbook has not been recognized as *.xls (BIFF-8) or *.xlsx (OOXML) file.
I am having the same issue following a Java update.
I was asking to load a .xlsx file to the function loadWorkbook() of the R XLConnect package.
I temporary solved the issue by asking to load an .xls file.
I also use OS X and after working without problem for a while with this function this error raises without apparent reason... But the reason is really simple. Excel (actually, all MS Office suite) creates temporary files meanwhile you have open the file. This file is hidden:
In my case, I list .xlsx files to open them inside a loop. So, the first file was a hidden file and the error raised. Closing excel (to delete those file) is the solution to avoid this error.
I'm trying to process docx file with Apache POI. Just simply read and then write file (just for now). Here is my simple code:
FileInputStream fileInputStream = new FileInputStream(inputFile);
XWPFDocument document = new XWPFDocument(OPCPackage.open(fileInputStream));
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
document.write(fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
fileInputStream.close();
Problem is that input file has small image in header. Because of that after processing input file with POI and opening output file in Microsoft Word I get corrupted file error :
Microsoft Office cannot open this file because some parts are missing or invalid.
Location: Part: /word/settings.xml, Line: 2, Column: 0
Everything works in OO Writer, but not in office.
The question is : what is wrong? Does apache POI not process files with image in header? Do you know any way to work around the problem?
I NEED to use Apache POI, I don't take into consideration other tools. Also I use POI 3.8
The problem is not with the image header but with the Apache POI jar version. Use the latest jars.
poi-3.10-FINAL.jar
poi-ooxml-3.10-FINAL.jar
poi-ooxml-schemas-3.10-FINAL.jar
ooxml-schemas-1.1.jar
Having the above jars solved the issue for me.
Need to change the old HSSFWorkbook based code XSSFWorkbook
Towards the task, i have added poi-3.9, poi-ooxml-schemas-3.9, poi-ooxml-3.9 jars to my build path and changed the code as suggested in
http://poi.apache.org/spreadsheet/converting.html
at XSSFWorkbook wb = new XSSFWorkbook() the flow control comes out of the flow at this line.
I try debugging the file, and observed that it was not able to create an instance for XSSFWorkbook.
But after reading from below url,
http://howtodoinjava.com/2013/06/19/readingwriting-excel-files-in-java-poi-tutorial/
i have added xmlbeans-2.3.0 jar, should i also add dom4j.jar also for this?
but still the same issue, control comes out from the line creation of instance for XSSFWorkbook. can any one please help me on this?
The issue is solved, after adding the dependent jar dom4j. Consolidating the details of jars needed for Apache POI 3.9 for XLSX format files to export are as follows,
Poi-,
poi-ooxml,
poi-ooxml-schems,
dom4j