Bug 38738 - Difference in Excel file between "Open and Save" versus "Save"
Summary: Difference in Excel file between "Open and Save" versus "Save"
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: PC Windows XP
: P2 major with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-21 17:39 UTC by Alex Zelinski
Modified: 2007-04-14 04:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Zelinski 2006-02-21 17:39:58 UTC
I am seeing a difference in the Excel file when I do a "Open and Save" from 
the File Dialog versus a "Save" only.  I tried to use a tool called DiffDoc 
that I found on the web to analyze the differences between the two files.  The 
tool could not open the file that I did not open before saving.
Comment 1 Andy Oliver 2006-02-21 18:32:02 UTC
Huh?  don't see a bug here
Comment 2 Alex Zelinski 2006-02-21 19:32:43 UTC
This is the error message that I receive when I try to upload the file that 
has only been saved - it was never opened.

2006-02-21 12:30:15,366 ERROR 
com.grainger.framework.struts.SystemExceptionHandl
er - execute() :
Error Code is 3
com.grainger.framework.exception.ApplicationException
Caused by:
com.grainger.framework.exception.ApplicationException
Caused by:
java.io.IOException: Unable to read entire block; 245 bytes read; expected 512 
b
ytes
        at org.apache.poi.poifs.storage.RawDataBlock.<init>
(RawDataBlock.java:99
)
        at org.apache.poi.poifs.storage.RawDataBlockList.<init>
(RawDataBlockList
.java:88)
        at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>
(POIFSFileSyste
m.java:123)
        at 
com.grainger.framework.document.handlers.impl.poi.ExcelDocumentHandle
r.initialize(Unknown Source)
        at com.grainger.framework.auth.upload.UploadMaster.initialize(Unknown 
So
urce)
        at 
com.grainger.fauth.ejb.session.UploadSessionFacadeBean.createReloadBa
tch(Unknown Source)
        at 
com.grainger.fauth.ejb.session.UploadSessionFacade_n7kmsw_EOImpl.crea
teReloadBatch(UploadSessionFacade_n7kmsw_EOImpl.java:46)
        at com.grainger.fauth.web.delegates.UploadDelegate.uploadBatch(Unknown 
S
ource)
        at com.grainger.fauth.web.actions.UploadAction.processBatch(Unknown 
Sour
ce)
        at com.grainger.fauth.web.actions.UploadAction.execute(Unknown Source)
        at org.apache.struts.action.RequestProcessor.processActionPerform
(Reques
tProcessor.java:421)
        at com.grainger.framework.struts.LoginRequestProcessor.process(Unknown 
S
ource)
        at org.apache.struts.action.ActionServlet.process
(ActionServlet.java:116
4)
        at org.apache.struts.action.ActionServlet.doPost
(ActionServlet.java:415)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at 
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1006)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubIm
pl.java:419)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubIm
pl.java:315)
        at 
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6718)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs
(Authenticate
dSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs
(SecurityManager.java:
121)
        at weblogic.servlet.internal.WebAppServletContext.invokeServlet
(WebAppSe
rvletContext.java:3764)
        at weblogic.servlet.internal.ServletRequestImpl.execute
(ServletRequestIm
pl.java:2644)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Comment 3 Maulin 2006-07-03 05:32:23 UTC
Even i am getting a similar Exception when I try to upload the file that 
has only been saved - it was never opened.
The foll was the sequence of Actions:
1)I created an Excel File using POI APIs and saved it at a location (say
D:\POI-Files\Download\test1.xls)
2) Now Without opening the test1.xls file, i try to create a HSSFWorkbook as
follows:
HSSFWorkbook wrkBook = new HSSFWorkbook(new FileInputStream(filePath));
[here filePath is a String set to "D:\\POI-Files\\Download\\test1.xls"]

It gives me the foll Exception at the above line:
java.io.IOException: Unable to read entire block; 2 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:62)
at org.apache.poi.poifs.storage.RawDataBlockList.<init>(RawDataBlockList.java:51)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:86)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:210)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:191)
at com.project.web.ExcelHelper.getWorkbookFromFilePath(ExcelHelper.java:124)
...

Instead of using the new HSSFWorkbook(InputStream) method, i tried using the
following block of Code, but still the Exception Persists!!!
        {
        InputStream w_ipStream = new FileInputStream(a_filePath);

        // read entire stream into byte array:
        ByteArrayOutputStream byteOS = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int count;
        count= w_ipStream.read(buffer);
        System.out.println("getWorkbookFromFilePath count = "+count);
        while(count != -1)
        {
            byteOS.write(buffer,0,count);
            count=w_ipStream.read(buffer);
            System.out.println("getWorkbookFromFilePath count = "+count);
        }
        byteOS.close();
        byte[] allBytes = byteOS.toByteArray();

        // create workbook from array:
        InputStream byteIS = new ByteArrayInputStream(allBytes);

        return new HSSFWorkbook(byteIS);
        }

Comment 4 Yegor Kozlov 2007-04-14 04:11:12 UTC
In my experiments I wouldn't reproduce it. Looks like it is not a bug in 3.0 RC.

If you have a particular test case that still throws exception with the latest
3.0 RC jar, please upload it. Otherwise it's not a bug.

Yegor