opening a spreadsheet

asked 2017-07-10 06:01:13 +0800

raviteja22342 gravatar image raviteja22342

hi i have a requirement something like this .i have created a file menu with open and new. when i click on open a new window should open on screen display all the books in the given path and when the user selects and clicks on the "open book" button. the spreadsheet should open. i have create two file(jsp and zul)one for displaying the menubar and spreadsheet and other for the window that should open when i select open from menubar. i m getting null pointer exception when i click on "open book".



<zssjsp:window title="My First ZK Spreadsheet Application" apply="com.project.handler.openSpreadSheet" height="100%" width="100%" >="" <%--="" <zssjsp:button="" id="open" label="open"/> --%> <%-- <zssjsp:include src="/WEB-INF/mainMenubar.zul"></zssjsp:include> --%>

     <zssjsp:div  width="100%"  >
    <zssjsp:menubar id="mainMenubar" width="100%"> 
    <zssjsp:menu id="fileMenu" label="File" > 
    <zssjsp:menupopup id="fileMenupopup"> 
    <zssjsp:menuitem id="Openmenu" label="Openmenu" /> 
    <zssjsp:menuitem id="newfile" label="newfile"/>
    <zssjsp:div height="100%" width="100%">

<zssjsp:spreadsheet id="ss" vflex="1" hflex="1" maxvisiblerows="150" maxvisiblecolumns="40" showtoolbar="true" showsheetbar="true" showformulabar="true"/> </zssjsp:div> </zssjsp:window>


</body> </html>


<zk> <window title="Open Projects" border="normal" width="460px" position="center,center" closable="true" action="show: slideDown;hide: slideUp" apply="org.zkoss.bind.BindComposer,com.project.handler.openSpreadSheet" viewmodel="@id('vm') @init('com.project.handler.DynamicColumnModel')"> <grid model="@load(vm.dataList)"> <columns> <column foreach="${vm.columnList}" label="${each}"></column> </columns> <template name="model" var="r"> <row> <label foreach="${vm.columnList}" value="@bind(r)"></label> </row> </template>


java code for controller

package com.project.handler;

import java.io.File;

import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Listen; import org.zkoss.zk.ui.select.annotation.Wire; import org.zkoss.zss.api.Importer; import org.zkoss.zss.api.Importers; import org.zkoss.zss.api.model.Book; import org.zkoss.zss.ui.Spreadsheet; import org.zkoss.zul.Button; import org.zkoss.zul.Label; import org.zkoss.zul.Menu; import org.zkoss.zul.Window;

import com.htrunk.application.beans.UserBean;

public class openSpreadSheet extends SelectorComposer<component>{ @Wire Spreadsheet ss; @Wire Label Openmenu; @Wire Label Open; @Wire Label newfile;

 @Listen("onClick = #Openmenu" )
 public void openmenu() {

     Window window = (Window)Executions.createComponents(
                "open.zul", null, null);

// System.out.println("hurray"); //// String filename = "blank.xlsx"; // // ss.setSrc("/WEB-INF/"+filename); // ss.setSrc(getFile("hellozss (copy).xlsx")); //// System.out.println(ss.getSrc());.xlsx"); //

  @Listen("onClick = #Open" )
 public void open() {
     UserBean bean = new UserBean();

// System.out.println(""sss.getSrc()); ss.setSrc("/WEB-INF/hellozss.xlsx"); System.out.println(ss.getSrc()); // ss.setSrc("/root/Desktop/book/hellozss.xlsx"); // UserBean bean = new UserBean(); // bean.setFilename("blank.xlsx"); }

  @Listen("onClick = #newfile" )
     public void newfile(){

    public void doAfterCompose(Component comp) throws Exception {

// UserBean bean = new UserBean(); // String filename = bean.getFilename(); // if(filename==null){ // bean.setFilename("/root/Desktop/book/hellozss.xlsx"); // filename = bean.getFilename(); // } ////
//// System.out.println("filename"+filename); //// Importer importer = Importers.getImporter(); //// //Book book = importer.imports(getFile(filename), "sample");

} //

    private String getFile(String filename) {

        return "/root/Desktop/book/"+filename;


delete flag offensive retag edit
Be the first one to answer this question!
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

1 follower



Asked: 2017-07-10 06:01:13 +0800

Seen: 16 times

Last updated: Jul 10 '17

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