关于jxl 导出excel问题
FileInputStream in = new FileInputStream(paths+"/service/exportexl/yc.xls");
wb = Workbook.getWorkbook(in);
OutputStream os = response.getOutputStream();
WritableWorkbook wwb = Workbook.createWorkbook(os,wb);
WritableSheet ws = wwb.createSheet("Sheet1", 0);
System.out.println(ws+"xxxx");
//设置列宽
for(int i=0;i<8;i++){
ws.setColumnView(i,30);
}
SapBen sb=new SapBen();
WritableCell cell = ws.getWritableCell(0,1);
CellFormat cf = cell.getCellFormat();
Label lab = new Label(0,1,"单位:" );
lab.setCellFormat(cf);
ws.addCell(lab);
--- 这行报错为空指针异常
------解决方案--------------------确认一下CellFormat cf = cell.getCellFormat(); 中的cf是否为null
------解决方案--------------------ws.addCell(lab); --- 这行报错为
空指针异常
这一行就两个参数,
那么你挨个的输出一下ws和lab
看看哪个为空。