全世界没人知道jxl怎么设置excel背景图片的吗????回答优秀的另外加分!!!

解决方案 »

  1.   

    CSDN的人才们咧??? 正在崩溃中
      

  2.   

    lz 要的是 背景图片 还是往excel添加图片呢?
      

  3.   

    1、先编辑图片至需要的大小;
    2、将excel表打开,“格式-工作表-背景”,插入该编辑后的图片;
    3、全选该张excel表,右键,“设置单元格格式-图案选项卡”,将单元格底色选成白色;
    4、选中要显示背景的单元格区域,右键,“设置单元格格式-图案选项卡”,将单元格底色选成透明色。  这样搞就好啦!
      

  4.   

    WritableWorkbook wwb = Workbook.createWorkbook(new File(
    excelFileName));
    WritableSheet ws = wwb.createSheet("sheet1", 0);
    WritableCellFormat alignStyle = new WritableCellFormat(); // 单元格样式
    alignStyle.setBackground(Colour.AQUA);//设置excel的背景颜色。
    // also,The first parameter is column,the second parameter is row.
    // add normal label data
    Label label00 = new Label(0, 0, "Label00");
    ws.addCell(label00);
    // add font formating data
    WritableFont wf = new WritableFont(WritableFont.TIMES, 18,
    WritableFont.BOLD, true);
    WritableCellFormat wff = new WritableCellFormat(wf);
    Label label10 = new Label(1, 0, "Label10", wff);
    ws.addCell(label10);
    // add color font formating data
    WritableFont wf_color = new WritableFont(WritableFont.ARIAL, 10,
    WritableFont.NO_BOLD, false,
    UnderlineStyle.DOUBLE_ACCOUNTING, Colour.RED);
    WritableCellFormat wff_color = new WritableCellFormat(wf_color);
    wff_color.setBackground(Colour.GRAY_25); // set background coloe to
    // gray
    Label label20 = new Label(2, 0, "Label20", wff_color);
    ws.addCell(label20); // 合并单元格
    WritableFont wf_merge = new WritableFont(WritableFont.ARIAL, 10,
    WritableFont.NO_BOLD, false,
    UnderlineStyle.DOUBLE_ACCOUNTING, Colour.GREEN);
    WritableCellFormat wff_merge = new WritableCellFormat(wf_merge);
    wff_merge.setBackground(Colour.BLACK);
    Label label30 = new Label(3, 0, "Label30", wff_merge);
    ws.addCell(label30);
    Label label40 = new Label(4, 0, "Label40");
    ws.addCell(label40);
    Label label50 = new Label(5, 0, "Label50");
    ws.addCell(label50);
    // 合并 (0,3) (4,0)
    // attention : 如果合并后面的列不为空,那么就把后面格的内容清空,格式也是按前一个单元格的格式
    ws.mergeCells(3, 0, 4, 0); // 添加Number格式数据
    jxl.write.Number labelN = new jxl.write.Number(0, 1, 3.1415926);
    ws.addCell(labelN); // 添加带有formatting的Number对象
    jxl.write.NumberFormat nf = new jxl.write.NumberFormat("#.##");
    jxl.write.WritableCellFormat wcfN = new jxl.write.WritableCellFormat(
    nf);
    jxl.write.Number labelNF = new jxl.write.Number(1, 1, 3.1415926,
    wcfN);
    ws.addCell(labelNF); // 添加Boolean对象
    jxl.write.Boolean labelBoolean = new jxl.write.Boolean(2, 1, false);
    ws.addCell(labelBoolean); // 添加DateTime对象
    DateTime labelDT = new DateTime(3, 1, new Date());
    ws.addCell(labelDT); // 添加带有格式的DataTime数据
    DateFormat dtf = new DateFormat("yyyy-MM-dd hh:mm:ss");
    WritableCellFormat wcfDt = new WritableCellFormat(dtf);
    wcfDt.setBackground(Colour.YELLOW);
    DateTime labelDT_format = new DateTime(4, 1, new java.util.Date(),
    wcfDt);
    ws.addCell(labelDT_format);
    ws.mergeCells(4, 1, 5, 1); // 比较长,用两列来显示 wwb.write();
    wwb.close();
      

  5.   

    我只做过生成excel设置背景色,对于设置背景图片,这个好像暂时不能实现。
      

  6.   

     哎、CSDN就没有一个人会设置背景图片的!!!!
      

  7.   

    可以这样做,先做一个demo.xls,里面设置好背景图片,每次程序先读取这个excel,然后再输出.问题是背景图片死的,不能更换,读去demo.xls会花点时间//读入文件
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(
    "c:\\demo.xls"));
    HSSFWorkbook wb = new HSSFWorkbook(fs); // 输出文件
    FileOutputStream fileOut = new FileOutputStream("c:\\test.xls");
    wb.write(fileOut);
      

  8.   

    你的背景色是怎么设置的,我用的是excel2003,设置单元格格式->图案 没有问题
      

  9.   

    使用poi处理excel就可以了。目前jxl不支持水印功能