private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used
private DrawingManager2 drawingManager;
private List escherBSERecords = new ArrayList(); // EscherBSERecord
+ private WindowOneRecord windowOne;
private static POILogger log = POILogFactory.getLogger(Workbook.class);
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found palette record at " + k);
retval.records.setPalettepos( k );
+ case WindowOneRecord.sid:
+ if (log.check( POILogger.DEBUG ))
+ log.log(DEBUG, "found WindowOneRecord at " + k);
+ retval.windowOne = (WindowOneRecord) rec;
default :
}
records.add(rec);
// }
retval.records.setRecords(records);
+
+ if (retval.windowOne == null) {
+ retval.windowOne = (WindowOneRecord) retval.createWindowOne();
+ }
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "exit create workbook from existing file function");
return retval;
records.add( retval.createPassword() );
records.add( retval.createProtectionRev4() );
records.add( retval.createPasswordRev4() );
- records.add( retval.createWindowOne() );
+ retval.windowOne = (WindowOneRecord) retval.createWindowOne();
+ records.add( retval.windowOne );
records.add( retval.createBackup() );
retval.records.setBackuppos( records.size() - 1 );
records.add( retval.createHideObj() );
}
}
-
+
+ public WindowOneRecord getWindowOne() {
+ return windowOne;
+ }
+
public int addBSERecord(EscherBSERecord e)
{
createDrawingGroup();
public void setSheetOrder(String sheetname, int pos ) {
workbook.setSheetOrder(sheetname, pos);
}
+
+ /**
+ * sets the tab whose data is actually seen when the sheet is opened.
+ * This may be different from the "selected sheet" since excel seems to
+ * allow you to show the data of one sheet when another is seen "selected"
+ * in the tabs (at the bottom).
+ * @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
+ * @param index
+ */
+ public void setSelectedTab(short index) {
+ workbook.getWindowOne().setSelectedTab(index);
+ }
+
+ /**
+ * gets the tab whose data is actually seen when the sheet is opened.
+ * This may be different from the "selected sheet" since excel seems to
+ * allow you to show the data of one sheet when another is seen "selected"
+ * in the tabs (at the bottom).
+ * @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
+ * @return
+ */
+ public short getSelectedTab() {
+ return workbook.getWindowOne().getSelectedTab();
+ }
+
+ /**
+ * sets the first tab that is displayed in the list of tabs
+ * in excel.
+ * @param index
+ */
+ public void setDisplayedTab(short index) {
+ workbook.getWindowOne().setDisplayedTab(index);
+ }
+
+ /**
+ * sets the first tab that is displayed in the list of tabs
+ * in excel.
+ * @return
+ */
+ public short getDisplayedTab() {
+ return workbook.getWindowOne().getDisplayedTab();
+ }
public final static byte ENCODING_COMPRESSED_UNICODE = 0;
public final static byte ENCODING_UTF_16 = 1;
c.createSheet("Sheet4");
}
+
+ public void testWindowOneDefaults() {
+ HSSFWorkbook b = new HSSFWorkbook( );
+ try {
+ assertEquals(b.getSelectedTab(), 0);
+ assertEquals(b.getDisplayedTab(), 0);
+ } catch (NullPointerException npe) {
+ fail("WindowOneRecord in Workbook is probably not initialized");
+ }
+ }
+
+ public void testSheetSelection() {
+ HSSFWorkbook b = new HSSFWorkbook();
+ b.createSheet("Sheet One");
+ HSSFSheet s = b.createSheet("Sheet Two");
+ b.setSelectedTab((short) 1);
+ b.setDisplayedTab((short) 1);
+ assertEquals(b.getSelectedTab(), 1);
+ assertEquals(b.getDisplayedTab(), 1);
+ }
}
\ No newline at end of file