poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52142] Unable to read excel 2007 with structure locked
Date Mon, 07 Nov 2011 15:12:46 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52142

--- Comment #3 from suresh babu <suresh54145@gmail.com> 2011-11-07 15:12:46 UTC ---
I have created test.xlsx sheet and added text 'test' in the first cell. I have
added the latest jar files of poi 3.8 beta 4 version on build path.

Below is the code used to read the sheet.

           XSSFWorkbook workbook=null;
                InputStream inputStream = null;

                    inputStream = new FileInputStream(new
File("G:\\test.xlsx"));

                workbook=     new XSSFWorkbook(inputStream);
                XSSFSheet sheet=workbook.getSheetAt(0);
                XSSFRow row=sheet.getRow(0);
                XSSFCell cell=row.getCell(0);
                System.out.println("cell value is--"+cell.toString());

output:

cell value is--test

I used the review-->protect workbook-->protect structure and windows..then gave
'suresh' as password and save the excel sheet as 'test_structure_locked.xlsx'.

then I tried to read this new file with the below code. It seems it is not able
to read the excel sheet whose structure is locked.

 XSSFWorkbook workbook=null;
                InputStream inputStream = null;

                    inputStream = new FileInputStream(new
File("G:\\test_structure_locked.xlsx"));

                workbook=     new XSSFWorkbook(inputStream);
                XSSFSheet sheet=workbook.getSheetAt(0);
                XSSFRow row=sheet.getRow(0);
                XSSFCell cell=row.getCell(0);
                System.out.println("cell value is--"+cell.toString());

Error:
Exception in thread "main" org.apache.poi.POIXMLException:
org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should
contain a content type part [M1.13]
    at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:178)
    at com.poi.xssf.XSSFWorkBook.main(XSSFWorkBook.java:98)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package
should contain a content type part [M1.13]
    at
org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:148)
    at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:615)
    at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:229)
    at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
    ... 2 more





(In reply to comment #0)
> I am able to open the excel 2007 but when I protect it with structure
> locking..I am not able to open it. I am using poi-3.8.beta4.
> 
> I dont think something is wrong with excel sheet.
> 
> Code:
> 
>  XSSFWorkbook workbook=null;
>             InputStream inputStream = null;
> 
>                 inputStream = new FileInputStream(new File("G:\\test.xlsx"));
> 
>             workbook=     new XSSFWorkbook(inputStream);
> 
> 
> Error:
> 
> 
> Exception in thread "main" org.apache.poi.POIXMLException:
> org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should
> contain a content type part [M1.13]
>     at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
>     at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:178)
>     at com.poi.xssf.XSSFWorkBook.main(XSSFWorkBook.java:97)
> Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package
> should contain a content type part [M1.13]
>     at
> org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:148)
>     at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:615)
>     at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:229)
>     at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
>     ... 2 more

(In reply to comment #0)
> I am able to open the excel 2007 but when I protect it with structure
> locking..I am not able to open it. I am using poi-3.8.beta4.
> 
> I dont think something is wrong with excel sheet.
> 
> Code:
> 
>  XSSFWorkbook workbook=null;
>             InputStream inputStream = null;
> 
>                 inputStream = new FileInputStream(new File("G:\\test.xlsx"));
> 
>             workbook=     new XSSFWorkbook(inputStream);
> 
> 
> Error:
> 
> 
> Exception in thread "main" org.apache.poi.POIXMLException:
> org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should
> contain a content type part [M1.13]
>     at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
>     at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:178)
>     at com.poi.xssf.XSSFWorkBook.main(XSSFWorkBook.java:97)
> Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package
> should contain a content type part [M1.13]
>     at
> org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:148)
>     at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:615)
>     at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:229)
>     at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
>     ... 2 more

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message