-
FEATURED COMPONENTS
First time here? Check out the FAQ!
///prueba.zul
My form here shows a list of receipts, is there any way to export this list into a spreadsheet
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./win"?>
<window id="win" title="Consulta" border="2" use="Prueba" width="550px">
<listbox id="lstfacturas" mold="paging" pageSize="500" width="100%" height="200px" >
<listhead>
<listheader label="Serie" width="4%" sort="auto(cserfac)"/>
<listheader label="Numero" width="6%" sort="auto(cnumfac)"/>
<listheader label="F.Emisión" width="7%" sort="auto(dfecemi)" />
<listheader label="F.Vencm." width="7%" sort="auto(dfecven)"/>
<listheader label="Importe" width="6%" align="right" sort="auto(npreven)" />
<listheader label="Saldo" width="6%" align="right" />
</listhead>
<listitem self="@{each=factura}" >
<listcell label="@{factura.cserfac}" />
<listcell label="@{factura.cnumfac}" />
<listcell label="@{factura.dfecemi}" />
<listcell label="@{factura.dfecven}" />
<listcell label="@{factura.npreven}" />
<listcell label="@{factura.nsalfac}" />
</listitem>
</listbox>
<toolbar id="tb" sclass="vista" height="25px" style="background:#defeff repeat-x 0 0;padding-top:7px" align="end">
<toolbarbutton id="btn2" image="/img/Save.png" label="2010"
onClick="win.f2009()" />
</toolbar>
</window>
Hi
I write a simple bean to demo this
1. prepare a spreadsheet xls file, in this file, set up cells.
for example , you have a user bean
class User { String id; String name; public User (String id, String name) { this.id = id; this.name = name; } public void setId (String id) { this.id = id; } public String getId() { return id; } public void setName (String name) { this.name = name; } public String getName () { return name; } }
then you coud set up cell value like this, in the xls file, this is depend by your bean's method
=user.id =user.name
2. After you have the xls file, prepare a zul file, use spreadsheet.getBook().notifyChange() to ask spreadsheet to reload bean
here is the my sample code
<?page title="new page title" contentType="text/html;charset=UTF-8"?> <zk> <button label="set new user bean"> <attribute name="onClick"> user = new User("2", "Groovy"); spreadsheet.getBook().notifyChange(new String[]{"user"}); </attribute> </button> <spreadsheet id="spreadsheet" src="/spreadsheet/book.xls" maxrows="20" maxcolumns="10" height="350px" width="100%"> </spreadsheet> <zscript><![CDATA[ class User { String id; String name; public User (String id, String name) { this.id = id; this.name = name; } public void setId (String id) { this.id = id; } public String getId() { return id; } public void setName (String name) { this.name = name; } public String getName () { return name; } } User user = new User("1", "LaLa"); spreadsheet.getBook().notifyChange(new String[]{"user"}); ]]></zscript> </zk>
Asked: 2010-06-07 10:14:49 +0800
Seen: 295 times
Last updated: Jun 13 '10