diff options
author | Nick Burch <nick@apache.org> | 2008-05-16 17:08:40 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2008-05-16 17:08:40 +0000 |
commit | 8f9f5b0065db47207d4541091bd197ec96f49890 (patch) | |
tree | 61b55f4505d0b7c7c5fcfd05c773c392d2352f85 /src/java/org/apache/poi/hssf/usermodel | |
parent | fa33841f96bb4073eb4f784ebed66ef4f7568ad4 (diff) | |
download | poi-8f9f5b0065db47207d4541091bd197ec96f49890.tar.gz poi-8f9f5b0065db47207d4541091bd197ec96f49890.zip |
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-657131 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk
........
r653892 | josh | 2008-05-06 20:48:55 +0100 (Tue, 06 May 2008) | 1 line
Another attempt to fix unicode problems in functionMetadata.txt. Made that file pure ascii.
........
r653945 | nick | 2008-05-06 23:51:28 +0100 (Tue, 06 May 2008) | 1 line
Add disabled test for bug #44898, and slightly improve a few poifs related error messages
........
r654056 | nick | 2008-05-07 10:41:03 +0100 (Wed, 07 May 2008) | 1 line
Update a test to match the new warning on short files
........
r654356 | josh | 2008-05-08 01:52:05 +0100 (Thu, 08 May 2008) | 1 line
44950 - fixed HSSFFormulaEvaluator.evaluateInCell() and Area3DEval.getValue() also added validation for number of elements in AreaEvals
........
r654366 | josh | 2008-05-08 02:06:56 +0100 (Thu, 08 May 2008) | 1 line
tiny clean-up after r654356 (bug 44950)
........
r654649 | josh | 2008-05-09 00:02:43 +0100 (Fri, 09 May 2008) | 1 line
fixed mistake in FuncPtg.clone(), added test case, cleaned up outdated (since bug 13292) test method.
........
r654650 | josh | 2008-05-09 00:06:30 +0100 (Fri, 09 May 2008) | 1 line
removed unused constructor and old comment after r654649
........
r655216 | josh | 2008-05-11 02:30:56 +0100 (Sun, 11 May 2008) | 1 line
bug 23630 - fixed spelling mistake in constant name
........
r655278 | josh | 2008-05-11 09:15:39 +0100 (Sun, 11 May 2008) | 1 line
41187 - fixed HSSFSheet to properly read xls files without ROW records
........
r655282 | yegor | 2008-05-11 10:03:24 +0100 (Sun, 11 May 2008) | 1 line
Added boolean flag to turn on use of merged columns in autosize
........
r655912 | josh | 2008-05-13 16:25:51 +0100 (Tue, 13 May 2008) | 1 line
added test case for reported bug 44987
........
r656213 | yegor | 2008-05-14 11:15:00 +0100 (Wed, 14 May 2008) | 1 line
properly update TextSpecInfoAtom when parent text is changed
........
r656215 | yegor | 2008-05-14 11:18:00 +0100 (Wed, 14 May 2008) | 1 line
Support for embedded ActiveX objects: PowerPoint references them similar to embedded documents but in a different container: ExControl instead of ExEmbed
........
r656252 | yegor | 2008-05-14 13:42:30 +0100 (Wed, 14 May 2008) | 1 line
convert line breaks into internal ppt represenatation when changing text
........
r656699 | yegor | 2008-05-15 16:23:38 +0100 (Thu, 15 May 2008) | 1 line
added a set accessor for embedded ole data
........
r656757 | josh | 2008-05-15 18:49:23 +0100 (Thu, 15 May 2008) | 1 line
bug 45000 - Fixed NPE in ListLevel when numberText is null
........
r656893 | josh | 2008-05-16 00:30:08 +0100 (Fri, 16 May 2008) | 1 line
44523 - fixed workbook sheet selection and focus
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@657135 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel')
4 files changed, 199 insertions, 88 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index 0d2cfade4c..2c82348949 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -826,8 +826,7 @@ public class HSSFCell implements Cell int row=record.getRow(); short col=record.getColumn(); short styleIndex=record.getXFIndex(); - if ((cellType != CELL_TYPE_ERROR) && (cellType != CELL_TYPE_FORMULA)) - { + if (cellType != CELL_TYPE_ERROR) { setCellType(CELL_TYPE_ERROR, false, row, col, styleIndex); } (( BoolErrRecord ) record).setValue(value); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index 353ba18456..d62a7c23a0 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -21,7 +21,6 @@ import java.util.Iterator; import java.util.NoSuchElementException; import org.apache.poi.hssf.model.Sheet; -import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.record.CellValueRecordInterface; import org.apache.poi.hssf.record.RowRecord; import org.apache.poi.ss.usermodel.Cell; @@ -39,11 +38,9 @@ public final class HSSFRow implements Comparable, Row { // used for collections public final static int INITIAL_CAPACITY = 5; - //private short rowNum; + private int rowNum; private HSSFCell[] cells=new HSSFCell[INITIAL_CAPACITY]; -// private short firstcell = -1; -// private short lastcell = -1; /** * reference to low level representation @@ -63,7 +60,8 @@ public final class HSSFRow implements Comparable, Row { private Sheet sheet; - protected HSSFRow() + // TODO - ditch this constructor + HSSFRow() { } @@ -75,18 +73,12 @@ public final class HSSFRow implements Comparable, Row { * @param rowNum the row number of this row (0 based) * @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int) */ - - //protected HSSFRow(Workbook book, Sheet sheet, short rowNum) - protected HSSFRow(HSSFWorkbook book, Sheet sheet, int rowNum) + HSSFRow(HSSFWorkbook book, Sheet sheet, int rowNum) { this.rowNum = rowNum; this.book = book; this.sheet = sheet; - row = new RowRecord(); - row.setOptionFlags( (short)0x100 ); // seems necessary for outlining to work. - row.setHeight((short) 0xff); - row.setLastCol((short) -1); - row.setFirstCol((short) -1); + row = new RowRecord(rowNum); setRowNum(rowNum); } @@ -100,8 +92,7 @@ public final class HSSFRow implements Comparable, Row { * @param record the low level api object this row should represent * @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int) */ - - protected HSSFRow(HSSFWorkbook book, Sheet sheet, RowRecord record) + HSSFRow(HSSFWorkbook book, Sheet sheet, RowRecord record) { this.book = book; this.sheet = sheet; @@ -219,12 +210,11 @@ public final class HSSFRow implements Comparable, Row { * @param rowNum the row number (0-based) * @throws IndexOutOfBoundsException if the row number is not within the range 0-65535. */ - - //public void setRowNum(short rowNum) - public void setRowNum(int rowNum) - { - if ((rowNum < 0) || (rowNum > RowRecord.MAX_ROW_NUMBER)) - throw new IndexOutOfBoundsException("Row number must be between 0 and "+RowRecord.MAX_ROW_NUMBER+", was <"+rowNum+">"); + public void setRowNum(int rowNum) { + if ((rowNum < 0) || (rowNum > RowRecord.MAX_ROW_NUMBER)) { + throw new IllegalArgumentException("Invalid row number (" + rowNum + + ") outside allowable range (0.." + RowRecord.MAX_ROW_NUMBER + ")"); + } this.rowNum = rowNum; if (row != null) { @@ -236,8 +226,6 @@ public final class HSSFRow implements Comparable, Row { * get row number this row represents * @return the row number (0 based) */ - - //public short getRowNum() public int getRowNum() { return rowNum; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 0098e03a9d..f33570c10c 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -153,6 +153,7 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { int sloc = sheet.getLoc(); RowRecord row = sheet.getNextRow(); + boolean rowRecordsAlreadyPresent = row!=null; while (row != null) { @@ -177,6 +178,18 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet if ( ( lastrow == null ) || ( lastrow.getRowNum() != cval.getRow() ) ) { hrow = getRow( cval.getRow() ); + if (hrow == null) { + // Some tools (like Perl module Spreadsheet::WriteExcel - bug 41187) skip the RowRecords + // Excel, OpenOffice.org and GoogleDocs are all OK with this, so POI should be too. + if (rowRecordsAlreadyPresent) { + // if at least one row record is present, all should be present. + throw new RuntimeException("Unexpected missing row when some rows already present"); + } + // create the row record on the fly now. + RowRecord rowRec = new RowRecord(cval.getRow()); + sheet.addRow(rowRec); + hrow = createRowFromRecord(rowRec); + } } if ( hrow != null ) { @@ -983,12 +996,33 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet } /** + * Note - this is not the same as whether the sheet is focused (isActive) + * @return <code>true</code> if this sheet is currently selected + */ + public boolean isSelected() { + return getSheet().getWindowTwo().getSelected(); + } + /** * Sets whether sheet is selected. * @param sel Whether to select the sheet or deselect the sheet. */ public void setSelected( boolean sel ) { - getSheet().setSelected( sel ); + getSheet().getWindowTwo().setSelected(sel); + } + /** + * @return <code>true</code> if this sheet is currently focused + */ + public boolean isActive() { + return getSheet().getWindowTwo().isActive(); + } + /** + * Sets whether sheet is selected. + * @param sel Whether to select the sheet or deselect the sheet. + */ + public void setActive(boolean sel ) + { + getSheet().getWindowTwo().setActive(sel); } /** @@ -1690,6 +1724,23 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet * @param column the column index */ public void autoSizeColumn(short column) { + autoSizeColumn(column, false); + } + + /** + * Adjusts the column width to fit the contents. + * + * This process can be relatively slow on large sheets, so this should + * normally only be called once per column, at the end of your + * processing. + * + * You can specify whether the content of merged cells should be considered or ignored. + * Default is to ignore merged cells. + * + * @param column the column index + * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column + */ + public void autoSizeColumn(short column, boolean useMergedCells) { AttributedString str; TextLayout layout; /** @@ -1698,13 +1749,13 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet * '0' looks to be a good choice. */ char defaultChar = '0'; - + /** * This is the multiple that the font height is scaled by when determining the * boundary of rotated text. */ double fontHeightMultiple = 2.0; - + FontRenderContext frc = new FontRenderContext(null, true, true); HSSFWorkbook wb = new HSSFWorkbook(book); @@ -1716,21 +1767,27 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet int defaultCharWidth = (int)layout.getAdvance(); double width = -1; + rows: for (Iterator it = rowIterator(); it.hasNext();) { HSSFRow row = (HSSFRow) it.next(); HSSFCell cell = row.getCell(column); - boolean isCellInMergedRegion = false; - for (int i = 0 ; i < getNumMergedRegions() && ! isCellInMergedRegion; i++) { - isCellInMergedRegion = getMergedRegionAt(i).contains(row.getRowNum(), column); + if (cell == null) continue; + + int colspan = 1; + for (int i = 0 ; i < getNumMergedRegions(); i++) { + if (getMergedRegionAt(i).contains(row.getRowNum(), column)) { + if (!useMergedCells) { + // If we're not using merged cells, skip this one and move on to the next. + continue rows; + } + cell = row.getCell(getMergedRegionAt(i).getColumnFrom()); + colspan = 1+ getMergedRegionAt(i).getColumnTo() - getMergedRegionAt(i).getColumnFrom(); + } } - if (cell == null | isCellInMergedRegion) continue; - HSSFCellStyle style = cell.getCellStyle(); HSSFFont font = wb.getFontAt(style.getFontIndex()); - //the number of spaces to indent the text in the cell - int indention = style.getIndention(); if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) { HSSFRichTextString rt = cell.getRichStringCellValue(); @@ -1763,9 +1820,9 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet trans.concatenate( AffineTransform.getScaleInstance(1, fontHeightMultiple) ); - width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth + indention); + width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); } else { - width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth + indention); + width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); } } } else { @@ -1808,19 +1865,19 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet trans.concatenate( AffineTransform.getScaleInstance(1, fontHeightMultiple) ); - width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth + indention); + width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); } else { - width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth + indention); + width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); } } } - if (width != -1) { - if (width > Short.MAX_VALUE) { //calculated width can be greater that Short.MAX_VALUE! - width = Short.MAX_VALUE; - } - sheet.setColumnWidth(column, (short) (width * 256)); + } + if (width != -1) { + if (width > Short.MAX_VALUE) { //width can be bigger that Short.MAX_VALUE! + width = Short.MAX_VALUE; } + sheet.setColumnWidth(column, (short) (width * 256)); } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 547f761fb7..b4c3cf3c7d 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -382,16 +382,66 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm workbook.setSheetOrder(sheetname, pos); } + private void validateSheetIndex(int index) { + int lastSheetIx = sheets.size() - 1; + if (index < 0 || index > lastSheetIx) { + throw new IllegalArgumentException("Sheet index (" + + index +") is out of range (0.." + lastSheetIx + ")"); + } + } + /** - * 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 + * Selects a single sheet. This may be different to + * the 'active' sheet (which is the sheet with focus). + */ + public void setSelectedTab(int index) { + + validateSheetIndex(index); + int nSheets = sheets.size(); + for (int i=0; i<nSheets; i++) { + getSheetAt(i).setSelected(i == index); + } + workbook.getWindowOne().setNumSelectedTabs((short)1); + } + /** + * deprecated May 2008 + * @deprecated use setSelectedTab(int) */ public void setSelectedTab(short index) { - workbook.getWindowOne().setSelectedTab(index); + setSelectedTab((int)index); + } + public void setSelectedTabs(int[] indexes) { + + for (int i = 0; i < indexes.length; i++) { + validateSheetIndex(indexes[i]); + } + int nSheets = sheets.size(); + for (int i=0; i<nSheets; i++) { + boolean bSelect = false; + for (int j = 0; j < indexes.length; j++) { + if (indexes[j] == i) { + bSelect = true; + break; + } + + } + getSheetAt(i).setSelected(bSelect); + } + workbook.getWindowOne().setNumSelectedTabs((short)indexes.length); + } + /** + * Convenience method to set the active sheet. The active sheet is is the sheet + * which is currently displayed when the workbook is viewed in Excel. + * 'Selected' sheet(s) is a distinct concept. + */ + public void setActiveSheet(int index) { + + validateSheetIndex(index); + int nSheets = sheets.size(); + for (int i=0; i<nSheets; i++) { + getSheetAt(i).setActive(i == index); + } + workbook.getWindowOne().setActiveSheetIndex(index); } /** @@ -401,25 +451,46 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm * in the tabs (at the bottom). * @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean) */ + public int getActiveSheetIndex() { + return workbook.getWindowOne().getActiveSheetIndex(); + } + /** + * deprecated May 2008 + * @deprecated - Misleading name - use getActiveSheetIndex() + */ public short getSelectedTab() { - return workbook.getWindowOne().getSelectedTab(); + return (short) getActiveSheetIndex(); } + /** * sets the first tab that is displayed in the list of tabs * in excel. * @param index */ + public void setFirstVisibleTab(int index) { + workbook.getWindowOne().setFirstVisibleTab(index); + } + /** + * deprecated May 2008 + * @deprecated - Misleading name - use setFirstVisibleTab() + */ public void setDisplayedTab(short index) { - workbook.getWindowOne().setDisplayedTab(index); + setFirstVisibleTab(index); } /** - * sets the first tab that is displayed in the list of tabs - * in excel. + * sets the first tab that is displayed in the list of tabs in excel. + */ + public int getFirstVisibleTab() { + return workbook.getWindowOne().getFirstVisibleTab(); + } + /** + * deprecated May 2008 + * @deprecated - Misleading name - use getFirstVisibleTab() */ public short getDisplayedTab() { - return workbook.getWindowOne().getDisplayedTab(); + return (short) getFirstVisibleTab(); } /** @@ -580,17 +651,13 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm public HSSFSheet createSheet() { - -// if (getNumberOfSheets() == 3) -// throw new RuntimeException("You cannot have more than three sheets in HSSF 1.0"); HSSFSheet sheet = new HSSFSheet(this); sheets.add(sheet); - workbook.setSheetName(sheets.size() - 1, - "Sheet" + (sheets.size() - 1)); - WindowTwoRecord windowTwo = (WindowTwoRecord) sheet.getSheet().findFirstRecordBySid(WindowTwoRecord.sid); - windowTwo.setSelected(sheets.size() == 1); - windowTwo.setPaged(sheets.size() == 1); + workbook.setSheetName(sheets.size() - 1, "Sheet" + (sheets.size() - 1)); + boolean isOnlySheet = sheets.size() == 1; + sheet.setSelected(isOnlySheet); + sheet.setActive(isOnlySheet); return sheet; } @@ -601,23 +668,24 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm */ public HSSFSheet cloneSheet(int sheetNum) { - HSSFSheet srcSheet = (HSSFSheet)sheets.get(sheetNum); - String srcName = workbook.getSheetName(sheetNum); - if (srcSheet != null) { + validateSheetIndex(sheetNum); + HSSFSheet srcSheet = (HSSFSheet) sheets.get(sheetNum); + String srcName = workbook.getSheetName(sheetNum); HSSFSheet clonedSheet = srcSheet.cloneSheet(this); - WindowTwoRecord windowTwo = (WindowTwoRecord) clonedSheet.getSheet().findFirstRecordBySid(WindowTwoRecord.sid); - windowTwo.setSelected(sheets.size() == 1); - windowTwo.setPaged(sheets.size() == 1); + clonedSheet.setSelected(false); + clonedSheet.setActive(false); sheets.add(clonedSheet); - int i=1; + int i = 1; while (true) { - //Try and find the next sheet name that is unique + // Try and find the next sheet name that is unique String name = srcName; String index = Integer.toString(i++); - if (name.length()+index.length()+2<31) - name = name + "("+index+")"; - else name = name.substring(0, 31-index.length()-2)+"("+index+")"; + if (name.length() + index.length() + 2 < 31) { + name = name + "(" + index + ")"; + } else { + name = name.substring(0, 31 - index.length() - 2) + "(" + index + ")"; + } //If the sheet name is unique, then set it otherwise move on to the next number. if (workbook.getSheetIndex(name) == -1) { @@ -626,18 +694,18 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm } } return clonedSheet; - } - return null; } /** - * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns - * the high level representation. Use this to create new sheets. - * - * @param sheetname sheetname to set for the sheet. + * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and + * returns the high level representation. Use this to create new sheets. + * + * @param sheetname + * sheetname to set for the sheet. * @return HSSFSheet representing the new sheet. - * @throws IllegalArgumentException if there is already a sheet present with a case-insensitive - * match for the specified name. + * @throws IllegalArgumentException + * if there is already a sheet present with a case-insensitive + * match for the specified name. */ public HSSFSheet createSheet(String sheetname) @@ -649,9 +717,9 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm sheets.add(sheet); workbook.setSheetName(sheets.size() - 1, sheetname); - WindowTwoRecord windowTwo = (WindowTwoRecord) sheet.getSheet().findFirstRecordBySid(WindowTwoRecord.sid); - windowTwo.setSelected(sheets.size() == 1); - windowTwo.setPaged(sheets.size() == 1); + boolean isOnlySheet = sheets.size() == 1; + sheet.setSelected(isOnlySheet); + sheet.setActive(isOnlySheet); return sheet; } @@ -855,8 +923,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm HSSFPrintSetup printSetup = sheet.getPrintSetup(); printSetup.setValidSettings(false); - WindowTwoRecord w2 = (WindowTwoRecord) sheet.getSheet().findFirstRecordBySid(WindowTwoRecord.sid); - w2.setPaged(true); + sheet.setActive(true); } private NameRecord findExistingRowColHeaderNameRecord( int sheetIndex ) |