资源说明:因数据安全,需要将生成的报表xls,添加水印,所以自已在jxl中进行代码修改。
使用例子
public class testJxl {
public static void main(String[] args) throws Exception {
OutputStream out = new FileOutputStream("./aaaa.xls"); // 写入到FileInputStream
WritableWorkbook wwb= Workbook.createWorkbook(out);
WritableSheet ws1=wwb.createSheet("test1", 0) ; // 得到工作薄中的第一个工作表
File fileImg = new File("./kkkk.bmp");
byte imageData[] = new byte[(int)fileImg.length()];
FileInputStream fis = new FileInputStream(fileImg);
fis.read(imageData);
// must be 24 bit true-colour,bmp file
// * @param imageByte
// * @param widthPixel
// * @param heightPixel
ws1.setWaterMarkImage(imageData,459,142);
wwb.write();
wwb.close();
fis.close();
out.close();
}
}
附件:
1)jxl.jar 修改后的jxl.jar包
2)kkkk.bmp 水印图片
3)aaaa.xls 生成的xls文件,水印图片为kkkk.bmp
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。