[J2ee] 在线Excel编辑-zk下的zss3.0

在线编辑Excel-zk.zss 3.0 Demo

官方网址:http://www.zkoss.org/product/zkspreadsheet

实现了在线保存文件到后台

Web.xml配置:

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<listener>
		<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
	</listener>
	<servlet>
		<servlet-name>auEngine</servlet-name>
		<servlet-class>net.lazytek.j4t.servlet.ExcelServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>auEngine</servlet-name>
		<url-pattern>/zkau/*</url-pattern>
	</servlet-mapping>

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>
 Servlet代码:net.lazytek.j4t.servlet.ExcelServlet
package net.lazytek.j4t.servlet;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.zkoss.zk.au.http.DHtmlUpdateServlet;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zss.api.Exporters;
import org.zkoss.zss.jsp.JsonUpdateBridge;
import org.zkoss.zss.ui.Spreadsheet;

@SuppressWarnings("serial")
public class ExcelServlet extends DHtmlUpdateServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		super.doGet(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		super.doPost(request, response);
		final String desktopId = request.getParameter("dtid");
		final String zssUUid = request.getParameter("uuid_0");
		new JsonUpdateBridge(getServletContext(), request, response, desktopId) {
			protected void process(Desktop desktop) {
				try {
					Spreadsheet spreadsheet = (Spreadsheet) desktop.getComponentByUuidIfAny(zssUUid);
					if (spreadsheet != null) {
						String filePath = getServletContext().getRealPath(
								"/WEB-INF/books/" + spreadsheet.getBook().getBookName());
						Exporters.getExporter().export(spreadsheet.getBook(), new File(filePath));
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}.process();
	}
}

演示效果图: [J2ee] 在线Excel编辑-zk下的zss3.0_第1张图片 lib库太大 只列一下 jar文件名
commons-codec-1.5.jar
commons-fileupload-1.2.2.jar
commons-io-1.3.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
jcommon-1.0.17.jar
jfreechart-1.0.14.jar
log4j-1.2.13.jar
ooxml-schemas-1.1.jar
xmlbeans-2.3.0.jar
zcommon-6.5.4.jar
zel-6.5.4.jar
zk-6.5.4.jar
zkbind-6.5.4.jar
zkex-6.5.4.jar
zkplus-6.5.4.jar
zpoi-3.9.0.jar
zpoiex-3.9.0.jar
zss-3.0.0.jar
zssex-3.0.0.jar
zssjsp-3.0.0.jar
zul-6.5.4.jar
zweb-6.5.4.jar
官方lib下载地址:http://www.zkoss.org/download/zkspreadsheet
上面为评估版本: 正常运行有时间限制,请使用官方提供的ose版本 + zk ce版本
据说修改一下 zkex&zssex里的Runtime.java的相关代码 可以破解使用限制,想要体验稍长一点的可以去试一下!
商用的请支持正版!

 

你可能感兴趣的:(java,Web,Excel)