解决方案 »

  1.   

    保存文件内容的时候, 字段通过 \t 分开。就可以在Excel下面用啦。
      

  2.   

    保存成csv 直接用Excel打开会乱码,要用记事本打开转换一下编码,我要直接能用Excel打开看的。。
      

  3.   

    保存成csv 直接用Excel打开会乱码,要用记事本打开转换一下编码,我要直接能用Excel打开看的。。
      

  4.   

    用你的源码 cell.setEncoding(HSSFCell.ENCODING_UTF_16);这句代码编译通不过提示The method setEncoding(short) is undefined for the type HSSFCell
      

  5.   

    package com.neusoft.avnc.zzyc.zzyc_rest_test;import java.io.File;
    import java.io.IOException;
    import java.lang.reflect.Field;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.Semaphore;import jxl.Cell;
    import jxl.CellType;
    import jxl.DateCell;
    import jxl.NumberCell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;/* 
     * 解析excel,并且封装为bean,存入数据库 
     */
    public class WriteToExcel { // list存放数据, filename是excel存放的路径以及名称
    public static void ExportExcel(List<ExcelParameterBean> list,
    String filename) { try {
    WritableWorkbook book = Workbook.createWorkbook(new File(
    "F:\\write.xls"));
    WritableSheet sheet = book.createSheet("sheet1", 0); // 添加表头, 第一个参数是列,第二个是行
    Label label1 = new Label(0, 0, "id"); // 第一列第一行
    Label label2 = new Label(1, 0, "comand"); // 第二列第一行
    Label label3 = new Label(2, 0, "request"); // 第二列第一行
    Label label4 = new Label(3, 0, "exresponse"); // 第二列第一行
    Label label5 = new Label(4, 0, "response"); // 第二列第一行
    Label label6 = new Label(5, 0, "checkResult"); // 第二列第一行
    Label label7 = new Label(6, 0, "RequestNum"); // 第二列第一行
    Label label8 = new Label(7, 0, "ConcurrentNum"); // 第二列第一行
    Label label9 = new Label(8, 0, "ResponseTime"); // 第二列第一行
    Label label10 = new Label(9, 0, "Minprocesstime"); // 第二列第一行
    Label label11 = new Label(10, 0, "Maxprocesstime"); // 第二列第一行
    Label label12 = new Label(11, 0, "Processability"); // 第二列第一行
    Label label13 = new Label(12, 0, "WrongNum"); // 第二列第一行
    Label label14 = new Label(13, 0, "Url"); // 第二列第一行 // 添加到sheet1中
    sheet.addCell(label1);
    sheet.addCell(label2);
    sheet.addCell(label3);
    sheet.addCell(label4);
    sheet.addCell(label5);
    sheet.addCell(label6);
    sheet.addCell(label7);
    sheet.addCell(label8);
    sheet.addCell(label9);
    sheet.addCell(label10);
    sheet.addCell(label11);
    sheet.addCell(label12);
    sheet.addCell(label13);
    sheet.addCell(label14); if (list.size() != 0) {
    Iterator it = list.iterator();
    int i = 1; // 表示行
    while (it != null && it.hasNext()) {
    ExcelParameterBean stu = (ExcelParameterBean) it.next();
    Label l1 = new Label(0, i, stu.getId());
    Label l2 = new Label(1, i, stu.getCommand());
    Label l3 = new Label(2, i, stu.getRequest());
    Label l4 = new Label(3, i, stu.getExresponse());
    Label l5 = new Label(4, i, stu.getResponse());
    Label l6 = new Label(5, i, stu.getCheckResult());
    Label l7 = new Label(6, i, stu.getRequestNum());
    Label l8 = new Label(7, i, stu.getConcurrentNum());
    Label l9 = new Label(8, i, stu.getResponseTime());
    Label l10 = new Label(9, i, stu.getMinprocesstime());
    Label l11 = new Label(10, i, stu.getMaxprocesstime());
    Label l12 = new Label(11, i, stu.getProcessability());
    Label l13 = new Label(12, i, stu.getWrongNum());
    Label l14 = new Label(13, i, stu.getUrl()); sheet.addCell(l1);
    sheet.addCell(l2);
    sheet.addCell(l3);
    sheet.addCell(l4);
    sheet.addCell(l5);
    sheet.addCell(l6);
    sheet.addCell(l7);
    sheet.addCell(l8);
    sheet.addCell(l9);
    sheet.addCell(l10);
    sheet.addCell(l11);
    sheet.addCell(l12);
    sheet.addCell(l13);
    sheet.addCell(l14);
    i++;
    }
    book.write();
    book.close();
    } } catch (Exception e) {
    System.out.println(e.getMessage());
    }
    }
    }
    屌不屌?我做过读取Excel,修改后再输出Excel,要全套代码可以加我QQ631747554