Set Dimension of the Sheet"

From Documentation
m
m (correct highlight (via JWB))
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{ZKSpreadsheetEssentialsPageHeader}}
 
{{ZKSpreadsheetEssentialsPageHeader}}
 +
 +
{{Deprecated|url=http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials}}
 +
 +
  
 
__TOC__
 
__TOC__
  
 
===Purpose===
 
===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.
+
ZK Spreadsheet can switch different sheets using <javadoc directory="zss" 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.
  
 
===ZUML===
 
===ZUML===
<source lang="xml" high="3,4">
+
<source lang="xml" highlight="3,4">
 
<zk>
 
<zk>
 
<div height="100%" width="100%" apply="demo.SheetsComposer">
 
<div height="100%" width="100%" apply="demo.SheetsComposer">
Line 20: Line 24:
 
</source>
 
</source>
  
===Retrieve sheet name===
+
===Composer===
We can get number of sheet from Book, and we can get sheet name by index.
+
====Retrieve Sheet Name====
<source lang="java" high="8,10">
+
We can get the number of sheet from Book, and we can get the sheet name by index.
 +
<source lang="java" highlight="8,10">
 
Combobox sheets;
 
Combobox sheets;
 
Spreadsheet spreadsheet;
 
Spreadsheet spreadsheet;
Line 41: Line 46:
  
 
[[File:ZKSsEss_Spreadsheet_DimSheet_Select.png]]
 
[[File:ZKSsEss_Spreadsheet_DimSheet_Select.png]]
===Select sheet===
+
 
Select sheet by Spreadsheet.setSelectedSheet()
+
====Select Sheet====
<source lang="java" high="2">
+
Select sheet by <javadoc directory="zss" method="setSelectedSheet(java.lang.String)">org.zkoss.zss.ui.Spreadsheet</javadoc>
 +
<source lang="java" highlight="2">
 
public void onSelect$sheets(Event event) {
 
public void onSelect$sheets(Event event) {
 
spreadsheet.setSelectedSheet(sheets.getText());
 
spreadsheet.setSelectedSheet(sheets.getText());
Line 50: Line 56:
  
 
[[File:ZKSsEss_Spreadsheet_DimSheet_Result.png]]
 
[[File:ZKSsEss_Spreadsheet_DimSheet_Result.png]]
 +
 +
View complete source of ZUML [https://code.google.com/p/zkbooks/source/browse/trunk/zssessentials/examples/WebContent/config/setSheet.zul setSheet.zul]
 +
 +
View complete source of composer [https://code.google.com/p/zkbooks/source/browse/trunk/zssessentials/examples/src/org/zkoss/zssessentials/config/SheetDimensionComposer.java SheetDimensionComposer.java]
 +
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}

Latest revision as of 12:56, 19 January 2022


Stop.png This article is out of date, please refer to http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials for more up to date information.


Purpose

ZK Spreadsheet can switch different sheets 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 the number of sheet from Book, and we can get the 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(String)

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

ZKSsEss Spreadsheet DimSheet Result.png

View complete source of ZUML setSheet.zul

View complete source of composer SheetDimensionComposer.java

Version History

Last Update : 2022/01/19


Version Date Content
     


All source code listed in this book is at Github.


Last Update : 2022/01/19

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