Summary: | sheet selection does not work | ||
---|---|---|---|
Product: | POI | Reporter: | Christian Sage <csage> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | CLOSED FIXED | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.5-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | other | ||
Attachments: |
WindowOneRecord's selectedTab and displayedTab are made accessible via usermodel api
Updated the patch file after recent changes for RICHTEXT |
Description
Christian Sage
2004-04-10 09:16:11 UTC
I am having the same problem generating an excel file with 3 sheets via POI (poi-2.5-final-20040302.jar and Excel97 SR-2). When I store the file and open it with excel, the 3rd sheet is shown. Now I want to make sure, the 1st sheet (overview) shows up when the file is opened by someone. I tried the setSelected on the 1st sheet, but this only results in the tab for the 1st sheet having white background, but the 2nd is shown to the user. I found, I'm not the only one experiencing this problem: http://java2.5341.com/msg/78833.html So some people seem to be waiting for a solution. Thanks! I have the same problem. I have an excel file as template containing 12 sheets. The default selected sheet is the first sheet (by the time the excel template was saved). The program will select the sheet of the month that was selected from the screen. Below is the code snippet: workBook.getSheetAt(0).setSelected(false); //month is zero-based workBook.getSheetAt(reportMonth).setSelected(true); I hope that this would be fixed. I am using poi-2.5.1-final-20040804.jar I also tried using poi-bin-3.0-alpha1-20050704 but still, it was not yet fixed. Thank you very much! Created attachment 15841 [details]
WindowOneRecord's selectedTab and displayedTab are made accessible via usermodel api
HSSFSheet#setSelected(boolean) cause the "tab selection" in excel to be set -
which simply means that the tab is seen as selected but the actual data could
be from a different tab (sheet).
BiffViewer indicated that "Sheet selection" is actually controlled by
WindowOneRecord.selectedTab.
This patch adds setter/getters for the WindowOneRecord in Workbook which is
then used by newly added usermodel method HSSFWorkbook#setSelectedTab(short) to
set the selected sheet.
(Similarly, although not directly related to this bug, setDisplayedTab was
added to HSSFWorkbook to allow setting the default displayed "first" tab in
excel)
It must be noted that to get the exact effect of selecting a sheet you would
(after this patch) need to use:
for (...) { // cycle over all sheets in workbook
// causes previous selection to be deselected
sheet.setSelected(false);
}
sheet = workbook.getSheetAt(mySheetIndex);
// show the tab as selected
sheet.setSelected(true);
// show the data frm selected sheet
workbook.setSelectedTab((short) mySheetIndex);
Created attachment 16182 [details]
Updated the patch file after recent changes for RICHTEXT
This patch has now been applied to CVS (previous patch file was not applied to
CVS)
Basically, same as previous patch file: changes in this patch file are only due
to change of code in HSSFWorkbook and Workbook due to recent RICHTEXT changes.
Amol, If the patch has been applied to CVS, can the bug be closed? Jason Comment on attachment 16182 [details]
Updated the patch file after recent changes for RICHTEXT
send me this patch
(In reply to comment #6) > (From update of attachment 16182 [details] [edit]) > send me this patch > Verified fixed in POI trunk and 3.0-alpha2. |