0

export list to a spreadsheet

asked 2010-06-07 10:14:49 +0800

santiago gravatar image santiago
42

///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>

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2010-06-09 02:48:32 +0800

samchuang gravatar image samchuang
4084 4

Hi

you want to set the selected listcell to spreadsheet or you have a bean called "factura" and wanna export to spreadsheet ?

link publish delete flag offensive edit

answered 2010-06-09 11:39:23 +0800

santiago gravatar image santiago
42

hi thanks for answering

i have a bean callled factura and i want to export it to a spreadsheet

link publish delete flag offensive edit

answered 2010-06-13 21:54:55 +0800

samchuang gravatar image samchuang
4084 4

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>

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-06-07 10:14:49 +0800

Seen: 295 times

Last updated: Jun 13 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More