加载excel,刷新透视图和图表,另存为图片
Workbook wb=new Workbook("D:\\temptest\\file\\spireSample\\chart1_4.xlsm");
PivotTableCollection pivotTables = wb.getWorksheets().get(1).getPivotTables();
PivotTable tabel = pivotTables.get(0);
tabel.refreshData();
tabel.calculateData();
Worksheet worksheet=wb.getWorksheets().get(0);
int count = worksheet.getCharts().getCount();
System.out.println(count);
Chart chart=worksheet.getCharts().get(0);
chart.refreshPivotData();
chart.calculate();
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setCellAutoFit(true);
options.setOnePagePerSheet(true);
options.setPrintingPage(PrintingPageType.IGNORE_BLANK);
options.setDesiredSize(552, 300);
options.setImageType(ImageType.PNG);
options.setHorizontalResolution(256);
options.setVerticalResolution(256);
chart.toImage("D:\\temptest\\file\\spireSample\\111.png", options);