Bug 54803

Summary: Error opening XLSX after saving with a Drawing using POI
Product: POI Reporter: Jesu Petar Maglutac <jpmaglutac>
Component: XSSFAssignee: POI Developers List <dev>
Severity: normal CC: dominik.stadler, jpmaglutac
Priority: P2    
Version: 4.0.x-dev   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Sample Input

Description Jesu Petar Maglutac 2013-04-05 03:30:35 UTC
I seem to be running into a bug when I open a XLSX file (created in LibreOffice), add a drawing, and reopen the file.

I've been able to recreate how the bug occurs, and here is a snippet of the code that causes the bug:

FileInputStream file = new FileInputStream("file.xlsx");
XSSFWorkbook workbook = (XSSFWorkbook)WorkbookFactory.create(file);
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFDrawing drawing = sheet.createDrawingPatriarch();
FileOutputStream fos = new FileOutputStream("newfile.xlsx");
try {
	WorkbookFactory.create(new FileInputStream("newfile.xlsx"));
	System.out.println("Sucessful re-reading");
} catch (Exception e) {
	System.out.println("Error re - reading spreadsheet" + e.getMessage());

This is the exception that is caught:

org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part /xl/worksheets/_rels/sheet1.xml.rels does not have any content type ! Rule: Package require content types when retrieving a part from a package. [M.1.14]

	at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:224)
	at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269)
	at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:73)
Comment 1 Dominik Stadler 2013-05-25 16:00:53 UTC
I tried this with a small sample input file, but could not reproduce the problem. 

Can you attach the test-input file that you are using?
Comment 2 Jesu Petar Maglutac 2013-05-29 03:10:37 UTC
Created attachment 30338 [details]
Sample Input
Comment 3 Jesu Petar Maglutac 2013-05-29 03:15:12 UTC
Attached a sample input that produces the bug on my machine
Comment 4 Dominik Stadler 2013-05-30 15:35:25 UTC
Thanks, that reproduces the bug nicely, however I took a look and I myself (currently) lack the knowledge with POI to dig into this further, hopefully somebody else can step in...
Comment 5 Vadim 2019-04-16 15:13:55 UTC
I am filled with the same problem. Now is 2019 but bug is still no fixed?
Comment 6 Vadim 2019-04-16 15:17:10 UTC
*using POI 4.0.1
Comment 7 Andreas Beeker 2019-04-16 21:28:30 UTC
Fixed via r1857663
Comment 8 Dominik Stadler 2019-04-17 07:30:26 UTC
@vadim: this is a non-profit project, nobody is paid to work on it, so your best option to get progress is to provide testcases and patches or help with information and testing in other ways.