本帖最后由 Richard.Huang 于 2023-12-28 17:27 编辑
产品:GcExcel
版本:V6.2.1
我用附件的模板和如下代码测试 ,发现性能不是线性增长的,2000条记录以上就有点无法接受了,麻烦看下,这个怎么优化。
- public class DemoJavaDatasource3 {
- public static void main(String[] args) throws IOException {
- System.out.println("start at" + new Date());
- long start = System.currentTimeMillis();
- Workbook workbook = new Workbook();
- int index = 34;
- String rootPath = "";
- String templateFile = rootPath + index + ".template.xlsx";
- workbook.open(templateFile);
- List<DataRow> rows = new ArrayList<>();
- int repeat = 2000;
- for (int i = 0; i < repeat; ++i) {
- rows.add(new DataRow("https://www.grapecity.com/spreadjs/demos/spread/source/logo-en.ico"));
- }
- workbook.addDataSource("ds", rows);
- workbook.processTemplate();
- workbook.save(rootPath + index + ".result.xlsx");
- System.out.println("time: " + (System.currentTimeMillis() - start) / 1000.0);
- }
- public static class DataRow {
- private String imgUrl;
- public DataRow(String imgUrl) {
- this.imgUrl = imgUrl;
- }
- public String getImgUrl() {
- return imgUrl;
- }
- public void setImgUrl(String imgUrl) {
- this.imgUrl = imgUrl;
- }
- }
- }
复制代码
|
|