Delete Range"
From Documentation
m (→Purpose) |
|||
Line 4: | Line 4: | ||
===Purpose=== | ===Purpose=== | ||
− | ZK Spreadsheet can use <javadoc directory="zss" method="delete(java.lang.Integer)">org.zkoss.zss.model.Range</javadoc> to delete range, | + | ZK Spreadsheet can use <javadoc directory="zss" method="delete(java.lang.Integer)">org.zkoss.zss.model.Range</javadoc> to delete range, rows or columns. |
===ZUML=== | ===ZUML=== |
Revision as of 08:15, 24 December 2010
Purpose
ZK Spreadsheet can use Range.delete(Integer) to delete range, rows or columns.
ZUML
<zk>
<div height="100%" width="100%" apply="demo.DeleteRangeComposer">
<div height="3px"></div>
<menupopup id="cellMenupopup">
<menuitem id="shiftCellLeft" label="Shift cells left"></menuitem>
<menuitem id="shiftCellUp" label="Shift cells up"/>
<menuitem id="deleteEntireRow" label="Entire row" />
<menuitem id="deleteEntireColumn" label="Entire column" />
</menupopup>
<spreadsheet id="spreadsheet" src="/demo_sample.xls"
maxrows="200"
maxcolumns="40"
width="100%"
height="450px"></spreadsheet>
</div>
</zk>
Composer
Open Menu
We can use onCellRightClick to get the current mouse position and open popup.
int rowIndex;
int colIndex;
Worksheet currentSheet;
Spreadsheet spreadsheet;
Menupopup cellMenupopup;
public void onCellRightClick$spreadsheet(CellMouseEvent event) {
rowIndex = event.getRow();
colIndex = event.getColumn();
currentSheet = event.getSheet();
cellMenupopup.open(event.getPageX(), event.getPageY());
}
Shift Cells Left
public void onClick$shiftCellLeft() {
Range rng = Ranges.range(currentSheet, rowIndex, colIndex);
rng.delete(Range.SHIFT_LEFT);
}
Shift Cells Up
public void onClick$shiftCellUp() {
final Range rng = Ranges.range(currentSheet, rowIndex, colIndex);
rng.delete(Range.SHIFT_UP);
}
Delete Entire Row
public void onClick$deleteEntireRow() {
Row row = currentSheet.getRow(rowIndex);
int lCol = row.getFirstCellNum();
int rCol = row.getLastCellNum();
Ranges.range(currentSheet, rowIndex, lCol, rowIndex, rCol).delete(Range.SHIFT_UP);
}
Delete Entire Column
public void onClick$deleteEntireColumn() {
int tRow = currentSheet.getFirstRowNum();
int bRow = currentSheet.getPhysicalNumberOfRows();
Ranges.range(currentSheet, tRow, colIndex, bRow, colIndex).delete(Range.SHIFT_LEFT);
}
Version History
Version | Date | Content |
---|---|---|
All source code listed in this book is at Github.