Bug 26455

Summary: Original sheet name cannnot be replaced to new one when not saved.
Product: POI Reporter: Tetsuji JUNICHO <junicho.tetsuji>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: critical    
Priority: P1    
Version: 2.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Java Source Code
The Excel WorkBook Before the sheet name is changed
The Excel WorkBook After the sheet name is changed

Description Tetsuji JUNICHO 2004-01-27 06:41:22 UTC
I can set a name of sheet, 
but the set name cannot be replaced to another.
For example, 

// create sheet
this.sheet = this.workbook.createSheet();

// set sheetname
this.workbook.setSheetName( 0, "SheetX", HSSFWorkbook.ENCODING_UTF_16 );

Then, I get the sheetname, which is is "SheetX".
Everything is neat so far, but
once I change the name to other one, say, "SheetY",
the sheet name becomes ".xls]SheetY".
The new name is unable to be changed anymore 
because it has "." and "]" which are unpermitted characters
in the sheetname.

Is anything wrong with the codes?
Comment 1 Tetsuji JUNICHO 2004-02-18 03:34:17 UTC
I found out a new fact.
The problem occurred only when I try to change a sheet name which is 
downloaded, opened and NOT SAVED.
Once the sheet is saved, its name can be changed safelly.

 
Comment 2 Jason Height 2004-02-18 04:22:27 UTC
Can you please submit some code that reproduces the error.

It would be beneficial to have a before and after save in excel file attached to
the bug. A simple diff of the biff records of the before and after would
probably pinpoint the problem.

Jason
Comment 3 Tetsuji JUNICHO 2004-02-19 10:16:24 UTC
Created attachment 10433 [details]
Java Source Code
Comment 4 Tetsuji JUNICHO 2004-02-19 10:17:23 UTC
Created attachment 10434 [details]
The Excel WorkBook Before the sheet name is changed
Comment 5 Tetsuji JUNICHO 2004-02-19 10:18:12 UTC
Created attachment 10435 [details]
The Excel WorkBook After the sheet name is changed
Comment 6 Tetsuji JUNICHO 2004-02-19 10:30:18 UTC
Hi, Jason.

I attached a simple Jave file which is simple, but still causes the error.
Also, I attached two Excel workbooks;
one is the one whose sheet name is not changed and
the other is the one whose sheet name is changed to "a" and
finally has the new sheet name ".xls]a".

NOTE:
Both sheet names ARE able to be changed now
because they have been SAVED.
However, if you check out the latter's biff
using org.apache.poi.hssf.dev.BiffViewer,
you will find a bunch of UNKNOWN codes.

Thanks

Ted 




Comment 7 Tetsuji JUNICHO 2004-05-28 09:06:47 UTC
Still has problems with version 2.5-final.
No clue??
Comment 8 ejb 2004-08-13 13:17:35 UTC
It's not a bug in POI, it's a bug in Excel!

The same problem was bugging me. And like the reporter of the bug said, the
problem only occurred before the file was saved.

I am generating XLS files from a struts action, and the problem with renaming
sheets in Excel only occurred if I opened the action's output directly in excel,
not if I saved it first.

After a while this pattern became appearant: any XLS file with square brackets
in the name (like any temporary file from MSIE, but also "my file [really].xls")
has the problem that Excel will behave strange if you change the name of a sheet
within it. The workaround is to give the file a name without brackets.

Unfortunately, you don't have a choice which name MSIE picks for a temporary
file when you open a downloaded file instead of saving it first.

Comment 9 Avik Sengupta 2004-08-13 13:32:05 UTC
Thanks for debugging this.. very helpful!