Bug 40414 - removing sheets leaves no selection -> printing problems
Summary: removing sheets leaves no selection -> printing problems
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: All All
: P4 minor (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-05 09:52 UTC by Meikel Bisping
Modified: 2008-05-16 12:21 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Meikel Bisping 2006-09-05 09:52:12 UTC
I had a number of sheets in my an excel template and removed all but one with poi.
When trying to print I got the error message "Did not find anything to print".
This disappeared when I added workbook.getSheetAt(0).setSelected(true).
Maybe you could make sure that a sheet is selected when sheets are removed.
Comment 1 Josh Micich 2008-05-16 12:21:55 UTC
Fixed in svn r657167 as a follow-on to bug 44523.

The suggested logic was applied within HSSFWorkbook.removeSheetAt(), to update both the active sheet index and selected sheet flags if the removed sheet was active or selected.

It seems that setting of the 'selected' sheet flags is the only thing important for this bug.  In Excel (2007) in the print dialog, the section 'Print what' has radio buttons with values 'Selection' and 'Active sheet(s)', suggesting that the 'active' sheet is used when that radio button is set.  From what I could tell, regardless of the value of the radio button, only the 'selected' sheet flags were taken into account.  

I left the fix to include the update of 'active' sheet because it seemed wrong to let the workbook have no active sheet, and it does no harm for this bug or any other existing test case.  Perhaps the observed behaviour related to printing is just a bug in Excel 2007.