JAVA导出WORD与EXCEL

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

package ais.mytest.web;

/**

* 功能:主要实现数据导出Excel和Word功能* 日期:2008-2-28

*/

import ais.basic.service.BasicUtil;

import mons.file.service.FileService; import ais.framework.web.BaseAction;

import ais.mytest.model.Employeer;

import ais.mytest.service.IemployeerService;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.text.DecimalFormat;

import jxl.write.NumberFormat;

import java.util.List;

import javax.servlet.ServletOutputStream; import jxl.Cell;

import jxl.Workbook;

import jxl.format.Alignment;

import jxl.format.UnderlineStyle;

import jxl.format.VerticalAlignment;

import jxl.format.Border;

import jxl.format.BorderLineStyle;

import jxl.format.BoldStyle;

import jxl.format.Colour;

import jxl.write.Blank;

import jxl.write.DateFormat;

import jxl.write.DateTime;

import bel;

import jxl.write.WritableCellFormat;

import jxl.write.WritableFont;

import jxl.write.WritableImage;

import jxl.write.WritableSheet;

import jxl.write.WritableWorkbook;

//import com.ibm.icu.text.SimpleDateFormat;

//import com.lowagie.text.Cell;

import com.lowagie.text.Document;

import com.lowagie.text.Font;

import com.lowagie.text.Image;

import com.lowagie.text.PageSize;

import com.lowagie.text.Paragraph;

import com.lowagie.text.Table;

import com.lowagie.text.pdf.BaseFont;

import com.lowagie.text.rtf.RtfWriter2;

import java.awt.Color;

import java.io.InputStream;

import java.io.OutputStream;

import org.apache.struts2.ServletActionContext;

public class ExportAction extends BaseAction{

/**

*

*/

private static final long serialVersionUID = -3951404867065653031L;

FileService fileService;

BasicUtil basicUtil;

IemployeerService iemployeerService;

Employeer employeer;

String filename=System.currentTimeMillis()+".doc";

public ExportAction() {}

/**

* 功能:将数据库中的数据导出word

* 日期:2008-2-29

* @return

*/

// 复制一份新的RTF文件

public String getNewFilePath() throws Exception {

InputStream ins = ServletActionContext.getServletContext().getResourceAsStream("/empty.doc");

byte[] b = new byte[ins.available()];

ins.read(b);

ins.close();

String newFileName = ServletActionContext.getServletContext().getRealPath("")+ "/"+filename;

OutputStream ous = new FileOutputStream(newFileName);

ous.write(b);

ous.close();

return newFileName;

}

// 将二进制流写到客户端

public void writeNewFile(String newFilePath, String downloadFileName)

throws Exception {

相关文档
最新文档