本帖最后由 Joestar.Xu 于 2024-2-23 17:29 编辑
产品:GcExcel
版本:V6.1.4
问题编号:DOCXLS-8825
last review: 2024-2-22
在V7.0.3中测试,未能重现该问题。
6万条数据,执行分页渲染,结果比较耗内存,大概要7个G,而且要等比较久,有没有什么优化的建议,或者是需要手动释放资源吗?
- public class DemoCsvDatasourcePageMem3 {
- public static void main(String[] args) throws IOException {
- int repeat = 30;
- for (int i=0;i<repeat;++i){
- run();
- }
- System.out.println("OK");
- }
- public static void run() throws IOException {
- long start = System.currentTimeMillis();
- String index = "27";
- String rootPath = "";
- Workbook workbook = new Workbook();
- String templateFile = rootPath+index+".template.xlsx";
- workbook.open(templateFile);
- System.out.println("open template cost: "+(System.currentTimeMillis() - start)/1000.0);
- String dataFile0 = rootPath+index+".ds0.json.txt";
- JsonDataSource datasource0 = new JsonDataSource(new String(Files.readAllBytes(Paths.get(dataFile0)), StandardCharsets.UTF_8));
- System.out.println("open data source cost: "+(System.currentTimeMillis() - start)/1000.0);
- workbook.addDataSource("ds0", datasource0);
- System.out.println("add data source cost: "+(System.currentTimeMillis() - start)/1000.0);
- boolean setPage = true;
- if(setPage){
- workbook.getNames().add("TemplateOptions.PaginationMode", "true");
- for (IWorksheet worksheet : workbook.getWorksheets()) {
- worksheet.getPageSetup().setPaperSize(PaperSize.A2);
- worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
- worksheet.getPageSetup().setFitToPagesWide(1);
- worksheet.getPageSetup().setIsPercentScale(false);
- }
- }
- workbook.processTemplate();
- System.out.println("process template cost: "+(System.currentTimeMillis() - start)/1000.0);
- String json = workbook.toJson();
- System.out.println("final cost: "+(System.currentTimeMillis() - start)/1000.0);
- }
- }
复制代码
|
|