Warning: Could not find named cell bb when parsing formula IF(G3="","",VLOOKUP(G3,bb!A:B,2,FALSE)) in cell aa!A1
jxl操作vlookup时,找不到表名,表名加上单引号即可
public static void write1() throws WriteException{
WritableWorkbook wwBook = null;
try {
wwBook = Workbook.createWorkbook(new File("d://aa.xls")); //创建工作薄
WritableSheet ws1 = wwBook.createSheet("aa", 0);//创建sheet
WritableSheet ws2 = wwBook.createSheet("bb", 0);//创建sheet
WritableCellFormat format2 = new WritableCellFormat(NumberFormats.DEFAULT);
format2.setLocked(false);
format2.setAlignment(jxl.format.Alignment.CENTRE);
//String formula = "IF(G3=\"\",\"\",VLOOKUP(G3,bb!A:B,2,FALSE))";
String formula = "IF(G3=\"\",\"\",VLOOKUP(G3,'bb'!A:B,2,FALSE))";//表名不加引号,会找不到表
WritableCell cell = new Formula(0,0, formula, format2);
ws1.addCell(cell);
wwBook.write();
wwBook.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}