Set Dimension of the Sheet"

From Documentation
m
m
Line 3: Line 3:
 
__TOC__
 
__TOC__
  
ZK Spreadsheet can switch different sheet using Spreadsheet.setSelectedSheet()
+
===Purpose===
 +
ZK Spreadsheet can switch different sheet using <javadoc method="setSelectedSheet(java.lang.String)">org.zkoss.zss.ui.Spreadsheet</javadoc>Spreadsheet. We use combobox to represent different sheets, user can click on it and select sheet.
  
==Scenario==
+
===ZUML===
We use combobox to represent different sheets, user can click on it and select sheet.
 
 
 
===ZUML Example===
 
 
<source lang="xml" high="3,4">
 
<source lang="xml" high="3,4">
 
<zk>
 
<zk>
Line 22: Line 20:
 
</source>
 
</source>
  
===Sheet name===
+
===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">

Revision as of 09:21, 22 November 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>

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);
}

ZKSsEss Spreadsheet DimSheet Select.png

Select sheet

Select sheet by Spreadsheet.setSelectedSheet()

public void onSelect$sheets(Event event) {
	spreadsheet.setSelectedSheet(sheets.getText());
}

ZKSsEss Spreadsheet DimSheet Result.png

Version History

Last Update : 2010/11/22


Version Date Content
     


All source code listed in this book is at Github.


Last Update : 2010/11/22

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.