Use JavaBean in Excel with ZK Spreadsheet 2.0.0"
(Created page with '{{Template:Smalltalk_Author| |author=Tony Wang, Engineer, Potix Corporation |date=Nov 4, 2010 |version=Applicable to ZK 5.0.4 and later ::Applicable to ZK Spreadsheet 2.0.0 EE a…') |
m |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 6: | Line 6: | ||
::Applicable to ZK Spreadsheet 2.0.0 EE and later | ::Applicable to ZK Spreadsheet 2.0.0 EE and later | ||
}} | }} | ||
+ | |||
+ | __TOC__ | ||
In this article, we will demonstrate how ZK Spreadsheet use external variables directly via Variable-Resolver. | In this article, we will demonstrate how ZK Spreadsheet use external variables directly via Variable-Resolver. | ||
Line 11: | Line 13: | ||
=Introduction= | =Introduction= | ||
− | In [ | + | In [[Small_Talks/2008/April/How_to_Build_a_Rich_Excel_Report_with_ZK_Spreadsheet|How to Build a Rich Excel Report with ZK Spreadsheet]], we demonstrate how to use name ranges to integrate data from Excel into ZK framework and vice versa. In this article, we will solve it with a more powerful feature - Variable-Resolver. Instead of saving values with defining name ranges and refreshing values of cells with method setCellValue, you only need to assign bean name in cells of Excel to get the data from the server side! In other words, values in cells will be refreshed dynamically by reloading data of bean! |
Let's start to build an application for calculating balance sheet with Variable-Resolver. | Let's start to build an application for calculating balance sheet with Variable-Resolver. | ||
− | |||
=Live Demo= | =Live Demo= | ||
Line 91: | Line 92: | ||
If you'd like to know more about ZK Spreadsheet, please refer to the following URLs: | If you'd like to know more about ZK Spreadsheet, please refer to the following URLs: | ||
− | * [ | + | * [[Small_Talks/2008/April/How_to_Build_a_Rich_Excel_Report_with_ZK_Spreadsheet|How to Build a Rich Excel Report with ZK Spreadsheet]] |
− | * [ | + | * [[Small_Talks/2010/December/New_Features_of_ZK_Spreadsheet_2.0.0_RC | New Features of ZK Spreadsheet 2.0.0 RC]] |
− | * [ | + | * [[Small_Talks/2007/December/A_Preview_of_ZK_Spreadsheet_Component | A Preview of ZK Spreadsheet Component]] |
− | * [ | + | * [[Small_Talks/2007/September/A_Sip_of_the_ZK_Spreadsheet_Component | A Sip of the ZK Spreadsheet Component]] |
If you'd like to know more about Variable-Resolver, please refer to the following URL: | If you'd like to know more about Variable-Resolver, please refer to the following URL: | ||
− | * [ | + | * [[Small_Talks/2007/November/Using_ZK_JndiVariableResolver_-_Retrieve_Session_Beans_and_EntityManagerFactory | Using ZK JndiVariableResolver - Retrieve Session Beans and EntityManagerFactory]] |
Latest revision as of 08:07, 18 January 2011
Tony Wang, Engineer, Potix Corporation
Nov 4, 2010
Applicable to ZK 5.0.4 and later
- Applicable to ZK Spreadsheet 2.0.0 EE and later
In this article, we will demonstrate how ZK Spreadsheet use external variables directly via Variable-Resolver.
Introduction
In How to Build a Rich Excel Report with ZK Spreadsheet, we demonstrate how to use name ranges to integrate data from Excel into ZK framework and vice versa. In this article, we will solve it with a more powerful feature - Variable-Resolver. Instead of saving values with defining name ranges and refreshing values of cells with method setCellValue, you only need to assign bean name in cells of Excel to get the data from the server side! In other words, values in cells will be refreshed dynamically by reloading data of bean!
Let's start to build an application for calculating balance sheet with Variable-Resolver.
Live Demo
ERROR: Width and Height not set
How to Build a Template Using Excel
Define the Layout Template in Excel
You can design the format of Excel data:
Input External Variable in Spreadsheet
Input bean and its data names in BalanceSheet.xls, such as dataBean.item, dataBean.liquidAssets, dataBean.fundInvestment etc.
ERROR: Width and Height not set
Get Values via Variable-Resolver
sheet.zul
<window>
Quarter:
<listbox id="quarter" mold="select" rows="1" onSelect="refreshQuarter()">
<listitem value="0" label="Select"/>
<listitem value="1" label="Quarter 1"/>
<listitem value="2" label="Quarter 2"/>
<listitem value="3" label="Quarter 3"/>
<listitem value="4" label="Quarter 4"/>
</listbox>
<zscript>
import model.Database;
import model.DataBean;
void refreshQuarter() {
Listitem listitem = quarter.getSelectedItem();
int quarter = Integer.parseInt(listitem.value);
//Resolve variable data bean via ZssVariableResolver
reloadQuarter(quarter,dataBean);
//Call the method to refresh values of cells
balance.book.notifyChange(new String[]{"dataBean"});
}
void reloadQuarter(int quarter,DataBean dataBean){
//Call the method to reload data
new Database().reloadQuarter(quarter,dataBean);
}
DataBean dataBean = new DataBean();
//initial data
dataBean = new Database().reloadQuarter(0, dataBean);
</zscript>
<spreadsheet id="balance" src="/BalanceSheet.xls" maxrows="40" maxcolumns="20" height="600px" width="1300px"/>
</window>
Summary
In recent release of ZK Spreadsheet, developers can even bind Java Bean into a spreadsheet application as a data. That means you can got data from database or otherwhere ,so you can do more data control .It's really helpful for use a exists Excel file as template , and show dynamic data online.
If you have any questions or suggestions, please feel free to leave comments here or post to ZK forum.
Download
Reference
If you'd like to know more about ZK Spreadsheet, please refer to the following URLs:
- How to Build a Rich Excel Report with ZK Spreadsheet
- New Features of ZK Spreadsheet 2.0.0 RC
- A Preview of ZK Spreadsheet Component
- A Sip of the ZK Spreadsheet Component
If you'd like to know more about Variable-Resolver, please refer to the following URL:
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |