Using Spreadsheet in JSP"
Line 32: | Line 32: | ||
# Create a simple Excel file or use the sample file in our example project. Put the file under your web application's root folder. | # Create a simple Excel file or use the sample file in our example project. Put the file under your web application's root folder. | ||
# Create <tt>index.jsp</tt> with content below: | # Create <tt>index.jsp</tt> with content below: | ||
− | <source lang= | + | <source lang='xml' high='11,14'> |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" | ||
pageEncoding="ISO-8859-1"%> | pageEncoding="ISO-8859-1"%> | ||
Line 43: | Line 43: | ||
</head> | </head> | ||
<body> | <body> | ||
− | <%@ taglib prefix=" | + | <%@ taglib prefix="zssjsp" uri="http://www.zkoss.org/jsp/zss"%> |
<div width="100%" style="height: 100%;"> | <div width="100%" style="height: 100%;"> | ||
− | < | + | <zssjsp:spreadsheet |
id="myzss" src="/WEB-INF/hellozss.xlsx" width="100%" | id="myzss" src="/WEB-INF/hellozss.xlsx" width="100%" | ||
height="800px" maxrows="200" maxcolumns="40" showSheetbar="true"/> | height="800px" maxrows="200" maxcolumns="40" showSheetbar="true"/> | ||
Line 52: | Line 52: | ||
</html> | </html> | ||
</source> | </source> | ||
+ | * Line 11: Declare a taglib before using Spreadsheet JSP tag is necessary. | ||
+ | * Line 13: Use spreadsheet JSP tag with prefix you specified previously. | ||
− | + | Now, deploy the project to your application server and visit <tt>index.jsp</tt> to see if you can see the Spreadsheet. | |
= usage in JSP = | = usage in JSP = |
Revision as of 10:06, 29 July 2013
Available in ZK Spreadsheet EE only
Download ZSS JSP Example Project
If you want to run ZK spreadsheet JSP demo in your local site, just [http:// download the example project WAR file] and deploy to your application server.
Create and Run a JSP Project
Follow instructions in ZK Spreadsheet Essentials 3/Working with Spreadsheet/Setting Up Environment to create a "dynamic web project" or a "maven project" named myzssjsp then do the following extra steps for using in JSP.
Extra Steps for Eclipse Dynamic Web Project
This feature is only available in EE, so you should download EE version. (Free Evaluation Download or Premium Download). After you install ZK Spreadsheet library, make sure zssjsp.jar existed under /WEB-INF/lib.
Extra Steps for Maven Project
In addition to org.zkoss.zss:zssex and org.zkoss.zk:zkmax, you should add the dependency (zssjsp) below:
<dependency>
<groupId>org.zkoss.zss</groupId>
<artifactId>zssjsp</artifactId>
<version>${zss.version}</version>
</dependency>
Verify Your Project
After completing above steps, preparation for working with Spreadsheet and JSP is done. You can use a simple page to verify your preparation. Steps are as follows:
- Create a simple Excel file or use the sample file in our example project. Put the file under your web application's root folder.
- Create index.jsp with content below:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My First ZK Spreadsheet JSP application</title>
<zssjsp:head/>
</head>
<body>
<%@ taglib prefix="zssjsp" uri="http://www.zkoss.org/jsp/zss"%>
<div width="100%" style="height: 100%;">
<zssjsp:spreadsheet
id="myzss" src="/WEB-INF/hellozss.xlsx" width="100%"
height="800px" maxrows="200" maxcolumns="40" showSheetbar="true"/>
</div>
</body>
</html>
- Line 11: Declare a taglib before using Spreadsheet JSP tag is necessary.
- Line 13: Use spreadsheet JSP tag with prefix you specified previously.
Now, deploy the project to your application server and visit index.jsp to see if you can see the Spreadsheet.