找回密码
 立即注册

QQ登录

只需一步,快速开始

葡萄种子
金牌服务用户   /  发表于:2023-9-1 19:23  /   查看:1491  /  回复:3
本帖最后由 Joestar.Xu 于 2024-2-23 17:29 编辑

产品:GcExcel
版本:V6.1.4
问题编号:DOCXLS-8825
last review: 2024-2-22
在V7.0.3中测试,未能重现该问题。

6万条数据,执行分页渲染,结果比较耗内存,大概要7个G,而且要等比较久,有没有什么优化的建议,或者是需要手动释放资源吗?
  1. public class DemoCsvDatasourcePageMem3 {
  2.     public static void main(String[] args) throws IOException {
  3.         int repeat = 30;
  4.         for (int i=0;i<repeat;++i){
  5.             run();
  6.         }
  7.         System.out.println("OK");
  8.     }
  9.     public static void run() throws IOException {
  10.         long start = System.currentTimeMillis();
  11.         String index = "27";
  12.         String rootPath = "";
  13.         Workbook workbook = new Workbook();
  14.         String templateFile = rootPath+index+".template.xlsx";
  15.         workbook.open(templateFile);
  16.         System.out.println("open template cost: "+(System.currentTimeMillis() - start)/1000.0);
  17.         String dataFile0 = rootPath+index+".ds0.json.txt";
  18.         JsonDataSource datasource0 = new JsonDataSource(new String(Files.readAllBytes(Paths.get(dataFile0)), StandardCharsets.UTF_8));
  19.         System.out.println("open data source cost: "+(System.currentTimeMillis() - start)/1000.0);
  20.         workbook.addDataSource("ds0", datasource0);
  21.         System.out.println("add data source cost: "+(System.currentTimeMillis() - start)/1000.0);
  22.         boolean setPage = true;
  23.         if(setPage){
  24.             workbook.getNames().add("TemplateOptions.PaginationMode", "true");
  25.             for (IWorksheet worksheet : workbook.getWorksheets()) {
  26.                 worksheet.getPageSetup().setPaperSize(PaperSize.A2);
  27.                 worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
  28.                 worksheet.getPageSetup().setFitToPagesWide(1);
  29.                 worksheet.getPageSetup().setIsPercentScale(false);
  30.             }
  31.         }
  32.         workbook.processTemplate();
  33.         System.out.println("process template cost: "+(System.currentTimeMillis() - start)/1000.0);
  34.         String json = workbook.toJson();
  35.         System.out.println("final cost: "+(System.currentTimeMillis() - start)/1000.0);
  36.     }
  37. }
复制代码







gc-excel-test27.zip

253.77 KB, 下载次数: 85

3 个回复

倒序浏览
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2023-9-4 17:58:25
沙发
本帖最后由 Clark.Pan 于 2023-10-19 13:28 编辑

您好,问题已复现,这边调研一下,后续有进展的话我会在本帖中回复您。

本帖先做保留处理,问题编号 DOCXLS-8825
回复 使用道具 举报
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2023-10-19 13:26:25
板凳
您好,更新一下最新的进展:
在GcExcel V7.0版本我们会对整个模板功能进行重构,该问题有望在重构后的模板中得到优化。
请您耐心等待。
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2024-2-22 15:09:55
地板
您好,V7.0版本已经在Maven上更新,您可以测试一下看看是否还存在该问题。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部