Insert Range"
From Documentation
m |
|||
Line 43: | Line 43: | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | [[File:ZKSsEss_Spreadsheet_InsertRange_Menu.png]] | ||
===Shift cells right=== | ===Shift cells right=== | ||
Line 52: | Line 54: | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | [[File:ZKSsEss_Spreadsheet_InsertRange_ShiftRight.png]] | ||
===Shift cells down=== | ===Shift cells down=== | ||
Line 60: | Line 64: | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | [[File:ZKSsEss_Spreadsheet_InsertRange_ShiftDown.png]] | ||
===Insert entire row=== | ===Insert entire row=== | ||
Line 73: | Line 79: | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | [[File:ZKSsEss_Spreadsheet_InsertRange_Row.png]] | ||
===Insert entire column=== | ===Insert entire column=== | ||
Line 85: | Line 93: | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | [[File:ZKSsEss_Spreadsheet_InsertRange_Column.png]] | ||
=Version History= | =Version History= |
Revision as of 01:05, 22 November 2010
ZK Spreadsheet can use Range.insert to inser row or column.
Scenario
User right click to open a menu and inert row or column.
ZUML Example
<zk>
<div height="100%" width="100%" apply="demo.InsertRangeComposer">
<div height="3px"></div>
<menupopup id="cellMenupopup">
<menuitem id="shiftCellRight" label="Shift cells right"></menuitem>
<menuitem id="shiftCellDown" label="Shift cells down"/>
<menuitem id="insertEntireRow" label="Entire row" />
<menuitem id="insertEntireColumn" label="Entire column" />
</menupopup>
<spreadsheet id="spreadsheet" src="/demo_sample.xls"
maxrows="200"
maxcolumns="40"
width="100%"
height="450px"></spreadsheet>
</div>
</zk>
We can use onCellRightClick to get the current mouse position and open popup.
int rowIndex;
int colIndex;
Sheet 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 right
Menuitem shiftCellRight;
public void onClick$shiftCellRight() {
Range rng = Ranges.range(currentSheet, rowIndex, colIndex);
rng.insert(Range.SHIFT_RIGHT, Range.FORMAT_RIGHTBELOW);
}
Shift cells down
public void onClick$shiftCellDown() {
final Range rng = Ranges.range(currentSheet, rowIndex, colIndex);
rng.insert(Range.SHIFT_DOWN, Range.FORMAT_LEFTABOVE);
}
Insert entire row
public void onClick$insertEntireRow() {
Row row = currentSheet.getRow(rowIndex);
int lCol = row.getFirstCellNum();
int rCol = row.getLastCellNum();
for(int colIdx = lCol; colIdx < rCol; colIdx++) {
final Range rng = Ranges.range(currentSheet, rowIndex, colIdx);
rng.insert(Range.SHIFT_DOWN, Range.FORMAT_LEFTABOVE);
}
}
Insert entire column
public void onClick$insertEntireColumn() {
int tRow = currentSheet.getFirstRowNum();
int bRow = currentSheet.getPhysicalNumberOfRows();
for (int rowIdx = tRow; rowIdx < bRow; rowIdx++) {
final Range rng = Ranges.range(currentSheet, rowIdx, colIndex);
rng.insert(Range.SHIFT_RIGHT, Range.FORMAT_RIGHTBELOW);
}
}
Version History
Version | Date | Content |
---|---|---|
All source code listed in this book is at Github.