如何在使用Java生成XLS文件时使用sum,avg,max和min等公式。
我正在使用jxl.write。*,我看到了很多apache-poi的例子。是否可以使用jxl执行相同的操作?
Label label;
WritableWorkbook workbook = Workbook.createWorkbook(file, wbSettings);
WorkbookSettings wbSettings = new WorkbookSettings();
wbSettings.setLocale(new Locale("en", "EN"));
workbook.createSheet("Report", 0);
WritableSheet excelSheet = workbook.getSheet(0);
label = new Label(column, row, "sample");
Number number = new Number(column, row, 60);
excelSheet.addCell(label);
excelSheet.addCell(number);
答案 0 :(得分:0)
String filename = "C:\\input.xls";
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook =
Workbook.createWorkbook(new File(filename), ws);
WritableSheet s = workbook.createSheet("Input", 0);
WritableSheet s1 = workbook.createSheet("Output", 1);
s1.addCell(new Number(3, 0, 5));
s1.addCell(new Number(3, 1, 6));
s1.addCell(new Number(3, 2, 1));
s1.addCell(new Number(3, 3, 6));
s1.addCell(new Number(3, 4, 1));
Formula formula = new Formula(3,5,"AVERAGE(D1:D5)");
s.addCell(formula);