@Test public void testZSS502_NonExistingSheet2007() { Book book = Util.loadBook(this, "book/blank.xlsx"); Sheet sheet = book.getSheetAt(0); Range cell = Ranges.range(sheet, "A1"); cell.setCellEditText("=nonExisted!B1"); assertEquals("=nonExisted!B1", cell.getCellEditText()); assertEquals(ErrorConstants.getText(ErrorConstants.ERROR_REF), cell.getCellFormatText()); }
@Test public void testZSS510() { Book book = Util.loadBook(this, "book/blank.xlsx"); Sheet sheet = book.getSheetAt(0); Range r = Ranges.range(sheet, "A1"); r.setCellEditText("Hello"); CellOperationUtil.applyDataFormat(r, ""); r.getCellFormatText(); // get text shouldn't cause IndexOutBoundaryException assertEquals( "General", r.getCellStyle().getDataFormat()); // should get General instead of empty string }
@Test public void testZSS502_2007() { Book book = Util.loadBook(this, "book/502-crossSheetReference.xlsx"); Sheet sheet = book.getSheet("cell-reference"); Range referencingCell = Ranges.range(sheet, "C4"); assertEquals("=row!A1", referencingCell.getCellEditText()); assertEquals("The first row is freezed.", referencingCell.getCellFormatText()); Ranges.range(book.getSheet("row")).deleteSheet(); assertEquals("='#REF'!A1", referencingCell.getCellEditText()); assertEquals( ErrorConstants.getText(ErrorConstants.ERROR_REF), referencingCell.getCellFormatText()); }
/* (non-Javadoc) * @see org.zkoss.zss.ui.sys.ua.impl.AbstractHandler#processAction(org.zkoss.zss.ui.UserActionContext) */ @Override protected boolean processAction(UserActionContext ctx) { Sheet sheet = ctx.getSheet(); AreaRef selection = ctx.getSelection(); CellSelectionType type = ctx.getSelectionType(); Range range = Ranges.range(sheet, selection); if (range.isProtected()) { showProtectMessage(); return true; } // zss-623, extends to row,column area switch (type) { case ROW: range = range.toRowRange(); break; case COLUMN: range = range.toColumnRange(); break; case ALL: // we don't allow to set whole sheet style, use column range instead range = range.toColumnRange(); } selection = new AreaRef(range.getRow(), range.getColumn(), range.getLastRow(), range.getLastColumn()); UndoableActionManager uam = ctx.getSpreadsheet().getUndoableActionManager(); uam.doAction( new CellStyleAction( Labels.getLabel("zss.undo.cellStyle"), sheet, selection.getRow(), selection.getColumn(), selection.getLastRow(), selection.getLastColumn(), CellOperationUtil.getVerticalAligmentApplier(_type))); return true; }