Bug 45707 - Error While opening Excel file written by POI
Summary: Error While opening Excel file written by POI
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: PC Windows Server 2003
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-28 08:56 UTC by Anirudh
Modified: 2009-12-31 13:46 UTC (History)
1 user (show)



Attachments
Main File Created By using POI (4.00 KB, application/vnd.ms-excel)
2008-08-28 08:56 UTC, Anirudh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anirudh 2008-08-28 08:56:40 UTC
Created attachment 22496 [details]
Main File Created By using POI 

There are two files.
1) Test-Main.xls --> Created by POI HSSF(Attached).
2) Test-Child.xls --> File create from excel software installed with Office.

Steps to Reproduce
EXCEL file created by POI(Test-Main.xls) as Biff8.0 doesn't work after linking CELLs to a master sheet created by excel opened using Microsoft Office(Test-Child.xls).

Recreate steps:
Case -1
1. Open a brand new workbook, lets call it"Test-Child.xls", leave it empty and save it.
2. Open File "Test-Main.xls" (find attached) created by using HSSF POI
3. Copy G3 cell value from "Test-Main.xls"
4. Do a Paste-Special-Link of those cells into "Test-Child.xls"
5. Save and close both workbooks
6. Open just "Test-Child.xls"
7. You will be prompted that this sheet has links, click Update.
8. It works fine.

Case -2 
1. Open a brand new workbook, lets call it "Test-Child.xls", leave it empty and save it.
2. Open File "Test-Main.xls" (find attached) created by using HSSF POI
3. Copy "F3" or "G5" cell value from "Test-Main.xls"
4. Do a Paste-Special-Link of those cells into "Test-Child.xls"
5. Save and close both workbooks
6. Open just "Test-Child.xls"
7. You will be prompted that this sheet has links, click Update.
8. You will then get an error that the link Cannot be updated
9. If you check the link staus you will see a note that the source sheet must be open.


Case -3
1. Open a brand new workbook, lets call it "Test-Child.xls", leave it empty and save it.
2. Open File "Test-Main.xls" (find attached) created by using HSSF POI
3. Copy "F3" or "G5" cell value from "Test-Main.xls"
4. Do a Paste-Special-Link of those cells into "Test-Child.xls"
5. Save and close both workbooks
6. Open just "Test-Child.xls"
7. You will be prompted that this sheet has links, click Update.
8. You will then get an error that the link Cannot be updated
9. If you check the link staus you will see a note that the source sheet must be open.
10. Close the "Test-Child.xls" workbook.
11. Open workbook "Test-Main.xls"
12. Change the value of F3 or G5 cells and save t.
13. Close the "Test-Main.xls" workbook.
14. Open "Test-Child.xls" workbook. It opens without any error!!!
Comment 1 Nick Burch 2008-08-28 09:53:48 UTC
POI 2.5 is over 4 years old...

Please re-try with a recent version of POI, and re-open the bug if the problem still remains.
Comment 2 Josh Micich 2008-08-28 10:37:46 UTC
The supplied POI generated file + Case-2 causes my Excel(2007) to completely crash.
Re-saving Test-Main.xls in Excel (even without changes) makes the problem go away. 

I couldn't reproduce the problem using latest svn trunk. So it looks like the bug was fixed (probably some time ago).

I tried regenerating a similar file (plain number cells, plain text cells).  Here is the code I used:

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");
sheet.createRow(0).createCell(1).setCellValue(123.456);
sheet.createRow(1).createCell(1).setCellValue(new HSSFRichTextString("abc.def"));
OutputStream os= new FileOutputStream("c:/temp/ex45707-linkDest.xls");
wb.write(os);
os.close();

After similar steps to Case-2 (linking to a text cell), the child spreadsheet had this formula:
='C:\temp\[ex45707-linkDest.xls]Sheet1'!$B$2

Re-opening the child (after closing all) does not cause a crash like it did before.  I ran through a few other variations of these use cases just to make sure there were no other problems.