Set Dimension of the Sheet"
From Documentation
Line 21: | Line 21: | ||
===Composer=== | ===Composer=== | ||
− | ====Retrieve | + | ====Retrieve Sheet Name==== |
We can get number of sheet from Book, and we can get sheet name by index. | We can get number of sheet from Book, and we can get sheet name by index. | ||
<source lang="java" high="8,10"> | <source lang="java" high="8,10"> | ||
Line 42: | Line 42: | ||
[[File:ZKSsEss_Spreadsheet_DimSheet_Select.png]] | [[File:ZKSsEss_Spreadsheet_DimSheet_Select.png]] | ||
− | ====Select | + | ====Select Sheet==== |
Select sheet by <javadoc method="setSelectedSheet(java.lang.String)">org.zkoss.zss.ui.Spreadsheet</javadoc> | Select sheet by <javadoc method="setSelectedSheet(java.lang.String)">org.zkoss.zss.ui.Spreadsheet</javadoc> | ||
<source lang="java" high="2"> | <source lang="java" high="2"> |
Revision as of 05:13, 2 December 2010
Purpose
ZK Spreadsheet can switch different sheet using Spreadsheet.setSelectedSheet(String)Spreadsheet. We use combobox to represent different sheets, user can click on it and select sheet.
ZUML
<zk>
<div height="100%" width="100%" apply="demo.SheetsComposer">
<combobox id="sheets"></combobox>
<spreadsheet id="spreadsheet" src="/demo_sample.xls"
maxrows="200"
maxcolumns="40"
width="100%"
height="450px"></spreadsheet>
</div>
</zk>
Composer
Retrieve Sheet Name
We can get number of sheet from Book, and we can get sheet name by index.
Combobox sheets;
Spreadsheet spreadsheet;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
List<String> sheetNames = new ArrayList<String>();
int sheetSize = spreadsheet.getBook().getNumberOfSheets();
for (int i = 0; i < sheetSize; i++){
sheetNames.add(spreadsheet.getSheet(i).getSheetName());
}
BindingListModelList model = new BindingListModelList(sheetNames, true);
sheets.setModel(model);
}
Select Sheet
Select sheet by Spreadsheet.setSelectedSheet(String)
public void onSelect$sheets(Event event) {
spreadsheet.setSelectedSheet(sheets.getText());
}
View complete source of ZUML setSheet.zul
View complete source of composer SheetDimensionComposer.java
Version History
Version | Date | Content |
---|---|---|
All source code listed in this book is at Github.