哪位大侠可以指点下啊?我用的是jdk1.5的jboss系统下运行下面这段代码OutputStream fout = new FileOutputStream("路径");
WritableWorkbook wwb = Workbook.createWorkbook(fout);WritableSheet ws=wwb.createSheet("sheet名", 0); jxl.write.WritableCellFormat wcfFC_col = new jxl.write.WritableCellFormat();
wcfFC_col.setWrap(true);
wcfFC_col.setBackground(Colour.LIGHT_GREEN);
wcfFC_col.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
WritableCellFormat colFormat = new WritableCellFormat(wcfFC_col);   
Label colLable = new Label(0, 1, "单元格",colFormat); 
         ws.addCell(colLable);

打印出的单元格为什么格式没有加上去啊,就是单元格出来了,没有背景色和字体格式。
在线等

解决方案 »

  1.   

    package test;import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;import jxl.Workbook;
    import jxl.format.Colour;
    import jxl.write.Label;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    import jxl.write.WriteException;
    import jxl.write.biff.RowsExceededException;public class JXLTest { /**
     * @param args
     */
    public static void main(String[] args) {
    try {
    OutputStream fout = new FileOutputStream("D:aaa.xls");
    WritableWorkbook wwb = Workbook.createWorkbook(fout); WritableSheet ws = wwb.createSheet("sheet名", 0); jxl.write.WritableCellFormat wcfFC_col = new jxl.write.WritableCellFormat();
    wcfFC_col.setWrap(true);
    wcfFC_col.setBackground(Colour.LIGHT_BLUE);
    wcfFC_col.setBorder(jxl.format.Border.ALL,
    jxl.format.BorderLineStyle.THIN);
    WritableCellFormat colFormat = new WritableCellFormat(wcfFC_col);
    Label colLable = new Label(0, 0, "单元格", colFormat);
    ws.addCell(colLable);
    wwb.write(); // 写入文件
    wwb.close();
    fout.close();
    File fl = new File("d:/aaa.xls");
    FileInputStream fis = new FileInputStream(fl);
    FileOutputStream f = new FileOutputStream("d:/aaa.zip");
    byte[] buf = new byte[1024];
    int len;
    BufferedOutputStream bos = new BufferedOutputStream(f);
    ZipOutputStream out = new ZipOutputStream(f);
    ZipEntry ze = new ZipEntry(fl.getName());// 这是压缩包名里的文件名
    out.putNextEntry(ze);// 写入新的 ZIP 文件条目并将流定位到条目数据的开始处 while ((len = fis.read(buf)) != -1) {
    out.write(buf, 0, len);
    out.flush();
    }
    fis.close();
    out.close();

    } catch (RowsExceededException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (WriteException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } }}
    我这样测试没有问题单元格也有格式,但是为什么放到jboss系统中就有问题了?
      

  2.   

    Label colLable = new Label(0, 1, "单元格",wcfFC_col);  
      格式这里用  wcfFC_col 这个 cellformat 试试。