dvt.addDataValidation(dvRecord);
}
-
- /**
- * @deprecated (Sep 2008) use {@link #setColumnHidden(int, boolean)}
- */
- public void setColumnHidden(short columnIndex, boolean hidden) {
- setColumnHidden(columnIndex & 0xFFFF, hidden);
- }
-
- /**
- * @deprecated (Sep 2008) use {@link #isColumnHidden(int)}
- */
- public boolean isColumnHidden(short columnIndex) {
- return isColumnHidden(columnIndex & 0xFFFF);
- }
-
- /**
- * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)}
- */
- public void setColumnWidth(short columnIndex, short width) {
- setColumnWidth(columnIndex & 0xFFFF, width & 0xFFFF);
- }
-
- /**
- * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
- */
- public short getColumnWidth(short columnIndex) {
- return (short) getColumnWidth(columnIndex & 0xFFFF);
- }
-
- /**
- * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)}
- */
- public void setDefaultColumnWidth(short width) {
- setDefaultColumnWidth(width & 0xFFFF);
- }
-
/**
* Get the visibility state for a given column.
*
* this worksheet values when the workbook is opened
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
*/
+ @Override
public void setForceFormulaRecalculation(boolean value) {
_sheet.setUncalced(value);
}
*
* @return true if an uncalced record must be inserted or not at generation
*/
+ @Override
public boolean getForceFormulaRecalculation() {
return _sheet.getUncalced();
}
*
* @param value true to vertically center, false otherwise.
*/
-
+ @Override
public void setVerticallyCenter(boolean value) {
_sheet.getPageSettings().getVCenter().setVCenter(value);
}
- /**
- * TODO: Boolean not needed, remove after next release
- *
- * @deprecated (Mar-2008) use getVerticallyCenter() instead
- */
- public boolean getVerticallyCenter(boolean value) {
- return getVerticallyCenter();
- }
-
/**
* Determine whether printed output for this sheet will be vertically centered.
*/
+ @Override
public boolean getVerticallyCenter() {
return _sheet.getPageSettings().getVCenter().getVCenter();
}
*
* @param value true to horizontally center, false otherwise.
*/
-
+ @Override
public void setHorizontallyCenter(boolean value) {
_sheet.getPageSettings().getHCenter().setHCenter(value);
}
/**
* Determine whether printed output for this sheet will be horizontally centered.
*/
-
+ @Override
public boolean getHorizontallyCenter() {
-
return _sheet.getPageSettings().getHCenter().getHCenter();
}
*
* @param value true for right to left, false otherwise.
*/
+ @Override
public void setRightToLeft(boolean value) {
_sheet.getWindowTwo().setArabic(value);
}
*
* @return whether the text is displayed in right-to-left mode in the window
*/
+ @Override
public boolean isRightToLeft() {
return _sheet.getWindowTwo().getArabic();
}
* @param index of the region to unmerge
*/
+ @Override
public void removeMergedRegion(int index) {
_sheet.removeMergedRegion(index);
}
*
* @return number of merged regions
*/
-
+ @Override
public int getNumMergedRegions() {
return _sheet.getNumMergedRegions();
}
- /**
- * @deprecated (Aug-2008) use {@link HSSFSheet#getMergedRegion(int)}
- */
- public org.apache.poi.hssf.util.Region getMergedRegionAt(int index) {
- CellRangeAddress cra = getMergedRegion(index);
-
- return new org.apache.poi.hssf.util.Region(cra.getFirstRow(), (short) cra.getFirstColumn(),
- cra.getLastRow(), (short) cra.getLastColumn());
- }
-
/**
* @return the merged region at the specified index
*/
+ @Override
public CellRangeAddress getMergedRegion(int index) {
return _sheet.getMergedRegionAt(index);
}
/**
* @return the list of merged regions
*/
+ @Override
public List<CellRangeAddress> getMergedRegions() {
List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>();
for (int i=0; i < _sheet.getNumMergedRegions(); i++) {
* be the third row if say for instance the second row is undefined.
* Call getRowNum() on each row if you care which one it is.
*/
+ @Override
public Iterator<Row> rowIterator() {
@SuppressWarnings("unchecked") // can this clumsy generic syntax be improved?
Iterator<Row> result = (Iterator<Row>) (Iterator<? extends Row>) _rows.values().iterator();
* @param numerator The numerator for the zoom magnification.
* @param denominator The denominator for the zoom magnification.
*/
+ @Override
public void setZoom(int numerator, int denominator) {
if (numerator < 1 || numerator > 65535)
throw new IllegalArgumentException("Numerator must be greater than 0 and less than 65536");
* @param toprow the top row to show in desktop window pane
* @param leftcol the left column to show in desktop window pane
*/
+ @Override
public void showInPane(int toprow, int leftcol) {
int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
if (toprow > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow);
* @param toprow the top row to show in desktop window pane
* @param leftcol the left column to show in desktop window pane
*/
- public void showInPane(short toprow, short leftcol) {
+ private void showInPane(short toprow, short leftcol) {
_sheet.setTopRow(toprow);
_sheet.setLeftCol(leftcol);
}
return new HSSFPatriarch(this, agg);
}
- /**
- * @deprecated (Sep 2008) use {@link #setColumnGroupCollapsed(int, boolean)}
- */
- public void setColumnGroupCollapsed(short columnNumber, boolean collapsed) {
- setColumnGroupCollapsed(columnNumber & 0xFFFF, collapsed);
- }
-
- /**
- * @deprecated (Sep 2008) use {@link #groupColumn(int, int)}
- */
- public void groupColumn(short fromColumn, short toColumn) {
- groupColumn(fromColumn & 0xFFFF, toColumn & 0xFFFF);
- }
-
- /**
- * @deprecated (Sep 2008) use {@link #ungroupColumn(int, int)}
- */
- public void ungroupColumn(short fromColumn, short toColumn) {
- ungroupColumn(fromColumn & 0xFFFF, toColumn & 0xFFFF);
- }
-
/**
* Expands or collapses a column group.
*
import org.apache.poi.hssf.util.PaneInformation;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.CellReference;
/**
* High level representation of a Excel worksheet.
*/
void showInPane(int toprow, int leftcol);
- /**
- * Sets desktop window pane display area, when the
- * file is first opened in a viewer.
- *
- * @param toprow the top row to show in desktop window pane
- * @param leftcol the left column to show in desktop window pane
- * @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows.
- */
- @Deprecated
- void showInPane(short toprow, short leftcol);
-
/**
* Shifts rows between startRow and endRow n number of rows.
* If you use a negative number, it will shift rows up.
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.SheetUtil;
import org.apache.poi.xssf.usermodel.XSSFComment;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
* Sets the protection enabled as well as the password
* @param password to set for protection. Pass <code>null</code> to remove protection
*/
+ @Override
public void protectSheet(String password)
{
_sh.protectSheet(password);
*
* @return true => protection enabled; false => protection disabled
*/
+ @Override
public boolean getScenarioProtect()
{
return _sh.getScenarioProtect();
* @param numerator The numerator for the zoom magnification.
* @param denominator The denominator for the zoom magnification.
*/
+ @Override
public void setZoom(int numerator, int denominator)
{
_sh.setZoom(numerator,denominator);
*
* @return short indicating the rownum (0 based) of the top row
*/
+ @Override
public short getTopRow()
{
return _sh.getTopRow();
*
* @return short indicating the rownum (0 based) of the top row
*/
+ @Override
public short getLeftCol()
{
return _sh.getLeftCol();
* @param toprow the top row to show in desktop window pane
* @param leftcol the left column to show in desktop window pane
*/
+ @Override
public void showInPane(int toprow, int leftcol)
{
_sh.showInPane(toprow, leftcol);
}
- /**
- * Sets desktop window pane display area, when the
- * file is first opened in a viewer.
- *
- * @param toprow the top row to show in desktop window pane
- * @param leftcol the left column to show in desktop window pane
- *
- * @deprecated Use the version of showInPane() with ints as there can be more than 32767 rows.
- */
- public void showInPane(short toprow, short leftcol)
- {
- _sh.showInPane(toprow, leftcol);
- }
-
/**
* Control if Excel should be asked to recalculate all formulas when the
* workbook is opened, via the "sheetCalcPr fullCalcOnLoad" option.
sel.setPane(pane.getActivePane());
}
- /**
- * Creates a new comment for this sheet. You still
- * need to assign it to a cell though
- *
- * @deprecated since Nov 2009 this method is not compatible with the common SS interfaces,
- * use {@link org.apache.poi.xssf.usermodel.XSSFDrawing#createCellComment
- * (org.apache.poi.ss.usermodel.ClientAnchor)} instead
- */
- @Deprecated
- public XSSFComment createComment() {
- return createDrawingPatriarch().createCellComment(new XSSFClientAnchor());
- }
-
/**
* Create a new row within the sheet and return the high level representation
*
}
/**
- * Sets the zoom magnication for the sheet. The zoom is expressed as a
+ * Sets the zoom magnification for the sheet. The zoom is expressed as a
* fraction. For example to express a zoom of 75% use 3 for the numerator
* and 4 for the denominator.
*
// check row numbers to make sure they are continuous and increasing (monotonic)
// and srcRows does not contain null rows
for (int index=1; index < srcRows.size(); index++) {
- final Row prevRow = srcRows.get(index-1);
final Row curRow = srcRows.get(index);
if (curRow == null) {
throw new IllegalArgumentException("srcRows may not contain null rows. Found null row at index " + index + ".");
getPane().setTopLeftCell(cellRef);
}
- /**
- * Location of the top left visible cell Location of the top left visible cell in the bottom right
- * pane (when in Left-to-Right mode).
- *
- * @param toprow the top row to show in desktop window pane
- * @param leftcol the left column to show in desktop window pane
- *
- * @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows.
- */
- @Override
- @Deprecated
- public void showInPane(short toprow, short leftcol) {
- showInPane((int)toprow, (int)leftcol);
- }
-
@Override
public void ungroupColumn(int fromColumn, int toColumn) {
CTCols cols = worksheet.getColsArray(0);
}
}
- /**
- * Assign a cell comment to a cell region in this worksheet
- *
- * @param cellRef cell region
- * @param comment the comment to assign
- * @deprecated since Nov 2009 use {@link XSSFCell#setCellComment(org.apache.poi.ss.usermodel.Comment)} instead
- */
- @Deprecated
- public static void setCellComment(String cellRef, XSSFComment comment) {
- CellReference cellReference = new CellReference(cellRef);
-
- comment.setRow(cellReference.getRow());
- comment.setColumn(cellReference.getCol());
- }
-
/**
* Register a hyperlink in the collection of hyperlinks on this sheet
*
safeGetProtectionField().setSheet(false);
}
- /**
- * Enable Autofilters locking.
- * @deprecated use {@link #lockAutoFilter(boolean)}
- */
- public void lockAutoFilter() {
- lockAutoFilter(true);
- }
-
/**
* Enable or disable Autofilters locking.
* This does not modify sheet protection status.
safeGetProtectionField().setAutoFilter(enabled);
}
- /**
- * Enable Deleting columns locking.
- * @deprecated use {@link #lockDeleteColumns(boolean)}
- */
- public void lockDeleteColumns() {
- lockDeleteColumns(true);
- }
-
/**
* Enable or disable Deleting columns locking.
* This does not modify sheet protection status.
safeGetProtectionField().setDeleteColumns(enabled);
}
- /**
- * Enable Deleting rows locking.
- * @deprecated use {@link #lockDeleteRows(boolean)}
- */
- public void lockDeleteRows() {
- lockDeleteRows(true);
- }
-
/**
* Enable or disable Deleting rows locking.
* This does not modify sheet protection status.
safeGetProtectionField().setDeleteRows(enabled);
}
- /**
- * Enable Formatting cells locking.
- * @deprecated use {@link #lockFormatCells(boolean)}
- */
- public void lockFormatCells() {
- lockFormatCells(true);
- }
-
/**
* Enable or disable Formatting cells locking.
* This does not modify sheet protection status.
safeGetProtectionField().setFormatCells(enabled);
}
- /**
- * Enable Formatting columns locking.
- * @deprecated use {@link #lockFormatColumns(boolean)}
- */
- public void lockFormatColumns() {
- lockFormatColumns(true);
- }
-
/**
* Enable or disable Formatting columns locking.
* This does not modify sheet protection status.
safeGetProtectionField().setFormatColumns(enabled);
}
- /**
- * Enable Formatting rows locking.
- * @deprecated use {@link #lockFormatRows(boolean)}
- */
- public void lockFormatRows() {
- lockFormatRows(true);
- }
-
/**
* Enable or disable Formatting rows locking.
* This does not modify sheet protection status.
safeGetProtectionField().setFormatRows(enabled);
}
- /**
- * Enable Inserting columns locking.
- * @deprecated use {@link #lockInsertColumns(boolean)}
- */
- public void lockInsertColumns() {
- lockInsertColumns(true);
- }
-
/**
* Enable or disable Inserting columns locking.
* This does not modify sheet protection status.
safeGetProtectionField().setInsertColumns(enabled);
}
- /**
- * Enable Inserting hyperlinks locking.
- * @deprecated use {@link #lockInsertHyperlinks(boolean)}
- */
- public void lockInsertHyperlinks() {
- lockInsertHyperlinks(true);
- }
-
/**
* Enable or disable Inserting hyperlinks locking.
* This does not modify sheet protection status.
safeGetProtectionField().setInsertHyperlinks(enabled);
}
- /**
- * Enable Inserting rows locking.
- * @deprecated use {@link #lockInsertRows(boolean)}
- */
- public void lockInsertRows() {
- lockInsertRows(true);
- }
-
/**
* Enable or disable Inserting rows locking.
* This does not modify sheet protection status.
safeGetProtectionField().setInsertRows(enabled);
}
- /**
- * Enable Pivot Tables locking.
- * @deprecated use {@link #lockPivotTables(boolean)}
- */
- public void lockPivotTables() {
- lockPivotTables(true);
- }
-
/**
* Enable or disable Pivot Tables locking.
* This does not modify sheet protection status.
safeGetProtectionField().setPivotTables(enabled);
}
- /**
- * Enable Sort locking.
- * @deprecated use {@link #lockSort(boolean)}
- */
- public void lockSort() {
- lockSort(true);
- }
-
/**
* Enable or disable Sort locking.
* This does not modify sheet protection status.
safeGetProtectionField().setSort(enabled);
}
- /**
- * Enable Objects locking.
- * @deprecated use {@link #lockObjects(boolean)}
- */
- public void lockObjects() {
- lockObjects(true);
- }
-
/**
* Enable or disable Objects locking.
* This does not modify sheet protection status.
safeGetProtectionField().setObjects(enabled);
}
- /**
- * Enable Scenarios locking.
- * @deprecated use {@link #lockScenarios(boolean)}
- */
- public void lockScenarios() {
- lockScenarios(true);
- }
-
/**
* Enable or disable Scenarios locking.
* This does not modify sheet protection status.
safeGetProtectionField().setScenarios(enabled);
}
- /**
- * Enable Selection of locked cells locking.
- * @deprecated use {@link #lockSelectLockedCells(boolean)}
- */
- public void lockSelectLockedCells() {
- lockSelectLockedCells(true);
- }
-
/**
* Enable or disable Selection of locked cells locking.
* This does not modify sheet protection status.
safeGetProtectionField().setSelectLockedCells(enabled);
}
- /**
- * Enable Selection of unlocked cells locking.
- * @deprecated use {@link #lockSelectUnlockedCells(boolean)}
- */
- public void lockSelectUnlockedCells() {
- lockSelectUnlockedCells(true);
- }
-
/**
* Enable or disable Selection of unlocked cells locking.
* This does not modify sheet protection status.
public void testWriteAutoFilter() throws Exception {
assertFalse(sheet.isAutoFilterLocked());
- sheet.lockAutoFilter();
+ sheet.lockAutoFilter(true);
assertFalse(sheet.isAutoFilterLocked());
sheet.enableLocking();
assertTrue(sheet.isAutoFilterLocked());
public void testWriteDeleteColumns() throws Exception {
assertFalse(sheet.isDeleteColumnsLocked());
- sheet.lockDeleteColumns();
+ sheet.lockDeleteColumns(true);
assertFalse(sheet.isDeleteColumnsLocked());
sheet.enableLocking();
assertTrue(sheet.isDeleteColumnsLocked());
public void testWriteDeleteRows() throws Exception {
assertFalse(sheet.isDeleteRowsLocked());
- sheet.lockDeleteRows();
+ sheet.lockDeleteRows(true);
assertFalse(sheet.isDeleteRowsLocked());
sheet.enableLocking();
assertTrue(sheet.isDeleteRowsLocked());
public void testWriteFormatCells() throws Exception {
assertFalse(sheet.isFormatCellsLocked());
- sheet.lockFormatCells();
+ sheet.lockFormatCells(true);
assertFalse(sheet.isFormatCellsLocked());
sheet.enableLocking();
assertTrue(sheet.isFormatCellsLocked());
public void testWriteFormatColumns() throws Exception {
assertFalse(sheet.isFormatColumnsLocked());
- sheet.lockFormatColumns();
+ sheet.lockFormatColumns(true);
assertFalse(sheet.isFormatColumnsLocked());
sheet.enableLocking();
assertTrue(sheet.isFormatColumnsLocked());
public void testWriteFormatRows() throws Exception {
assertFalse(sheet.isFormatRowsLocked());
- sheet.lockFormatRows();
+ sheet.lockFormatRows(true);
assertFalse(sheet.isFormatRowsLocked());
sheet.enableLocking();
assertTrue(sheet.isFormatRowsLocked());
public void testWriteInsertColumns() throws Exception {
assertFalse(sheet.isInsertColumnsLocked());
- sheet.lockInsertColumns();
+ sheet.lockInsertColumns(true);
assertFalse(sheet.isInsertColumnsLocked());
sheet.enableLocking();
assertTrue(sheet.isInsertColumnsLocked());
public void testWriteInsertHyperlinks() throws Exception {
assertFalse(sheet.isInsertHyperlinksLocked());
- sheet.lockInsertHyperlinks();
+ sheet.lockInsertHyperlinks(true);
assertFalse(sheet.isInsertHyperlinksLocked());
sheet.enableLocking();
assertTrue(sheet.isInsertHyperlinksLocked());
public void testWriteInsertRows() throws Exception {
assertFalse(sheet.isInsertRowsLocked());
- sheet.lockInsertRows();
+ sheet.lockInsertRows(true);
assertFalse(sheet.isInsertRowsLocked());
sheet.enableLocking();
assertTrue(sheet.isInsertRowsLocked());
public void testWritePivotTables() throws Exception {
assertFalse(sheet.isPivotTablesLocked());
- sheet.lockPivotTables();
+ sheet.lockPivotTables(true);
assertFalse(sheet.isPivotTablesLocked());
sheet.enableLocking();
assertTrue(sheet.isPivotTablesLocked());
public void testWriteSort() throws Exception {
assertFalse(sheet.isSortLocked());
- sheet.lockSort();
+ sheet.lockSort(true);
assertFalse(sheet.isSortLocked());
sheet.enableLocking();
assertTrue(sheet.isSortLocked());
public void testWriteObjects() throws Exception {
assertFalse(sheet.isObjectsLocked());
- sheet.lockObjects();
+ sheet.lockObjects(true);
assertFalse(sheet.isObjectsLocked());
sheet.enableLocking();
assertTrue(sheet.isObjectsLocked());
public void testWriteScenarios() throws Exception {
assertFalse(sheet.isScenariosLocked());
- sheet.lockScenarios();
+ sheet.lockScenarios(true);
assertFalse(sheet.isScenariosLocked());
sheet.enableLocking();
assertTrue(sheet.isScenariosLocked());
public void testWriteSelectLockedCells() throws Exception {
assertFalse(sheet.isSelectLockedCellsLocked());
- sheet.lockSelectLockedCells();
+ sheet.lockSelectLockedCells(true);
assertFalse(sheet.isSelectLockedCellsLocked());
sheet.enableLocking();
assertTrue(sheet.isSelectLockedCellsLocked());
public void testWriteSelectUnlockedCells() throws Exception {
assertFalse(sheet.isSelectUnlockedCellsLocked());
- sheet.lockSelectUnlockedCells();
+ sheet.lockSelectUnlockedCells(true);
assertFalse(sheet.isSelectUnlockedCellsLocked());
sheet.enableLocking();
assertTrue(sheet.isSelectUnlockedCellsLocked());
import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
+import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
sheet.onDocumentRead();
}
- @SuppressWarnings("deprecation")
+ /**
+ * This would be better off as a testable example rather than a simple unit test
+ * since Sheet.createComment() was deprecated and removed.
+ * https://poi.apache.org/spreadsheet/quick-guide.html#CellComments
+ * Feel free to relocated or delete this unit test if it doesn't belong here.
+ */
@Test
public void testCreateComment() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
+ ClientAnchor anchor = wb.getCreationHelper().createClientAnchor();
XSSFSheet sheet = wb.createSheet();
- assertNotNull(sheet.createComment());
+ XSSFComment comment = sheet.createDrawingPatriarch().createCellComment(anchor);
+ assertNotNull(comment);
wb.close();
}
/**
* Test vertically centered output.
*/
- @SuppressWarnings("deprecation")
@Test
public void verticallyCenter() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
VCenterRecord record = s.getSheet().getPageSettings().getVCenter();
assertFalse(record.getVCenter());
- assertFalse(s.getVerticallyCenter(true));
- assertFalse(s.getVerticallyCenter(false));
+ assertFalse(s.getVerticallyCenter());
s.setVerticallyCenter(true);
assertTrue(record.getVCenter());
- assertTrue(s.getVerticallyCenter(true));
- assertTrue(s.getVerticallyCenter(false));
+ assertTrue(s.getVerticallyCenter());
wb.close();
}
HCenterRecord record = s.getSheet().getPageSettings().getHCenter();
assertFalse(record.getHCenter());
+ assertFalse(s.getHorizontallyCenter());
s.setHorizontallyCenter(true);
assertTrue(record.getHCenter());
+ assertTrue(s.getHorizontallyCenter());
+
wb.close();
}
wb2.close();
}
- @SuppressWarnings("deprecation")
@Test
public void autoSizeColumn() throws IOException {
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("43902.xls");
//create a region over the 2nd row and auto size the first column
sheet.addMergedRegion(new CellRangeAddress(1,1,0,1));
- assertNotNull(sheet.getMergedRegionAt(0));
+ assertNotNull(sheet.getMergedRegion(0));
sheet.autoSizeColumn((short)0);
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);