当前位置: 代码迷 >> J2SE >> 怎么导出Excel表?
  详细解决方案

怎么导出Excel表?

热度:177   发布时间:2016-04-24 15:43:22.0
如何导出Excel表??????????
请各位帮帮我!!!!

------解决方案--------------------
有个直接读取与导出excel的包,我忘记名字了,在公司有用过,如果楼主明天还没有解决此问题,我传给你
------解决方案--------------------
poi
------解决方案--------------------
使用bufferWriter写出文件但在写出之前设计好它的扩展名为.xls

当然里面的数据间隔要用/t来表示这一个数据和下一个不是在同一个单元格里
------解决方案--------------------
jxl
------解决方案--------------------
poi.jar

------解决方案--------------------
1通过sql语句可以倒
2通过程序代码也可以。例如楼上 infon(阿槑) 的。

------解决方案--------------------
poi
------解决方案--------------------
mark
------解决方案--------------------
jxl.jar
网上很多``去下一个
------解决方案--------------------
jxl
------解决方案--------------------
jxl.jar工具就可以了:例子如下:

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import jxl.SheetSettings;
import jxl.Workbook;
import jxl.format.*;
import jxl.write.*;

public class PrinterServlet extends HttpServlet
{

private static final String CONTENT_TYPE = "text/html; charset=GBK ";

public PrinterServlet()
{
}

public void init()
throws ServletException
{
}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType( "text/html; charset=GBK ");
PrintWriter out = response.getWriter();
boolean bExportSucc = false;
String sErrorStr = " ";
String sHead = "/files/ ";
String sFileName = "Test.xls ";
String sCurrPath = request.getRealPath( "/files/ ");
File filepath = new File(sCurrPath);
if(filepath.exists())
out.println( "路径已经存在! <br> ");
else
filepath.mkdir();
sCurrPath = sCurrPath + "/ " + sFileName;
File file = new File(sCurrPath);
file.createNewFile();
String sUrlPath = sHead + sFileName;
try
{
WritableWorkbook workbook = Workbook.createWorkbook(new File(sCurrPath));
WritableSheet sheet = workbook.createSheet( "****信息管理系统 ", 0);
SheetSettings sheetset = sheet.getSettings();
sheetset.setProtected(false);
WritableFont NormalFont = new WritableFont(WritableFont.ARIAL, 10);
WritableFont BoldFont = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
WritableCellFormat wcf_left = new WritableCellFormat(NormalFont);
wcf_left.setBorder(jxl.format.Border.NONE, jxl.format.BorderLineStyle.THIN);
wcf_left.setVerticalAlignment(jxl.format.VerticalAlignment.TOP);
wcf_left.setAlignment(jxl.format.Alignment.LEFT);
wcf_left.setWrap(false);
WritableCellFormat wcf_right = new WritableCellFormat(NormalFont);
  相关解决方案