You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2014/10/29 12:57:14 UTC
[Bug 57163] New: Cannot delete a sheet in an XLS workbook
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
Bug ID: 57163
Summary: Cannot delete a sheet in an XLS workbook
Product: POI
Version: 3.11-dev
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
Assignee: dev@poi.apache.org
Reporter: PhiLho@GMX.net
When I want to delete a sheet that's not the last one in a workbook with
several sheets, I get an exception.
Exception in thread "main" java.lang.NullPointerException
at
org.apache.poi.hssf.model.InternalWorkbook.removeSheet(InternalWorkbook.java:780)
at
org.apache.poi.hssf.usermodel.HSSFWorkbook.removeSheetAt(HSSFWorkbook.java:924)
I open the file with:
try (InputStream in = new BufferedInputStream(new FileInputStream(new
File(fileName))))
{
return WorkbookFactory.create(in);
}
then I call workbook.removeSheetAt(0);
Apparently, the linkTable field is null.
My use case is to load a template with several sheets, delete them all but one
to clone it to the number of sheets needed.
As a workaround, I move the wanted sheet at first position with:
workbook.setSheetOrder(workbook.getSheetName(sheetIndex), 0);
then I delete all the others in reverse order...
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
Created attachment 32198
--> https://issues.apache.org/bugzilla/attachment.cgi?id=32198&action=edit
Proposed fix which adjusts the active sheet in setSheetOrder() and
removeSheet()
FYI, I have a proposed fix for this and bug 57171, but would like to postpone
checkin until after release 3.11 as it runs a slight risk of breaking stuff.
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
Nick Burch <ap...@gagravarr.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Can you attach a small file that shows this problem?
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
--- Comment #2 from Philippe Lhoste <Ph...@GMX.net> ---
Created attachment 32172
--> https://issues.apache.org/bugzilla/attachment.cgi?id=32172&action=edit
The Excel file used in the test
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
--- Comment #4 from Philippe Lhoste <Ph...@GMX.net> ---
Added a standalone class that loads the sample Excel file and reproduce the
bugs (three bugs are shown, I numbered them with the Bugzilla id).
You might need to adjust the path to the sample.
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
--- Comment #3 from Philippe Lhoste <Ph...@GMX.net> ---
Created attachment 32173
--> https://issues.apache.org/bugzilla/attachment.cgi?id=32173&action=edit
Show bugs
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
Philippe Lhoste <Ph...@GMX.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Cannot delete a sheet in an |Cannot delete an arbitrary
|XLS workbook |sheet in an XLS workbook
| |(only the last one)
OS| |All
--
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
[Bug 57163] Cannot delete an arbitrary sheet in an XLS workbook
(only the last one)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57163
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Dominik Stadler <do...@gmx.at> ---
Fixed this and Bug 57163 via r1647264
--
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