彩票走势图

彩票走势图 > 慧问 > 频道

透视图应该自动刷新,但是转为image是历史数据的图表[Aspose.Cells for Java]

发表于2020-03-09 回复:0 查看:4764  |  

apose-java用的是最新版本

运行工具: idea

代码:



Workbook workbook = new Workbook(filepath);
WorksheetCollection worksheets = workbook.getWorksheets();
Iterator<Worksheet> it = workbook.getWorksheets().iterator();
while (it.hasNext()) {
Worksheet worksheet = it.next();
worksheet.refreshPivotTables();

}
Worksheet worksheet = worksheets.get(sheetIndex);

String filename = filepath.substring(filepath.lastIndexOf(File.separator), filepath.lastIndexOf("."));
String fileDir = filepath.substring(0, filepath.lastIndexOf(File.separator));

String picName = filename + "_" + startPoint + "_" + endPoint + "_" + System.currentTimeMillis() + ".jpg"; // png

resultPath = fileDir + File.separator + picName;


System.out.println("resultPath: " + resultPath);
String printArea = startPoint + ":" + endPoint;
System.out.println("area: " + printArea);

worksheet.getPageSetup().setPrintArea(printArea);
worksheet.getPageSetup().setLeftMargin(1);
worksheet.getPageSetup().setRightMargin(1);
worksheet.getPageSetup().setTopMargin(1);
worksheet.getPageSetup().setBottomMargin(1);
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setOnePagePerSheet(true);
options.setDesiredSize(2560, 1440);
options.setImageFormat(ImageFormat.getJpeg());
// options.setCellAutoFit(true);
if (OPERATING_SYSTEM.contains("win")) {
CellsHelper.setFontDir("c:\\windows\\fonts");
} else {
CellsHelper.setFontDir("/usr/share/fonts/chinese");
}

SheetRender sheetRender = new SheetRender(worksheet, options);
System.out.println("size -> " + sheetRender.getPageCount());
for (int i = 0; i < sheetRender.getPageCount(); i++) {
sheetRender.toImage(i, resultPath);
}


0个回答

打破零回复...

回复

登录 慧都网发表评论

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP