• <menu id="w2i4a"></menu>
  • 首頁 > 慧問 > 頻道

    透視圖應該自動刷新,但是轉為image是歷史數(shù)據的圖表[Aspose.Cells for Java]

    發(fā)表于2020-03-09 回復:0 查看:4600  |  

    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個回答

    打破零回復...

    回復

    登錄 慧都網發(fā)表評論

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();