https://bz.apache.org/bugzilla/show_bug.cgi?id=65695
Bug ID: 65695
Summary: org.apache.poi.ss.extractor.EmbeddedExtractor extract
"xls" embedded file can not be opened by office excel
Product: POI
Version: 4.1.2-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 38097
--> https://bz.apache.org/bugzilla/attachment.cgi?id=38097&action=edit
this is origin excel template
I am trying to extract embedded files from excel using
`org.apache.poi.ss.extractor.EmbeddedExtractor`, But when the embedded file is
xls or xlsx, the extracted file can not be opened by office excel. Here is my
test case.
```
@Test
public void testExtractEmbeddedFiles() throws IOException {
Workbook workbook = WorkbookFactory.create(new File("template.xls"));
Sheet attachment1 = workbook.getSheet("attachment1");
EmbeddedExtractor extractor = new EmbeddedExtractor();
List<EmbeddedData> embeddedData = extractor.extractAll(attachment1);
for (EmbeddedData embeddedDatum : embeddedData) {
try (FileOutputStream output = new
FileOutputStream(System.currentTimeMillis() + ".xls")) {
org.apache.commons.io.IOUtils.write(embeddedDatum.getEmbeddedData(),
output);
}
}
workbook.close();
}
```
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]