本帖最后由 Richard.Huang 于 2024-5-17 11:43 编辑
产品:GcExcel
版本:V6.2.1
调研编号:DOCXLS-10379
GcExcel模板处理后边框部分丢失。可以用附件的模板和数据复现,处理后的exel效果如下:
代码如下:
- public class DemoJsonDatasource3 {
- public static void main(String[] args) throws IOException {
- String index = "41";
- Workbook workbook = new Workbook();
- String rootPath = "";
- String templateFile = rootPath + index + ".template.xlsx";
- workbook.open(templateFile);
- String dataFile0 = rootPath + index + ".ds0.json.txt";
- JsonDataSource datasource0 = new JsonDataSource(new String(Files.readAllBytes(Paths.get(dataFile0)), StandardCharsets.UTF_8));
- workbook.addDataSource("ds0", datasource0);
- String dataFile1 = rootPath + index + ".ds1.json.txt";
- JsonDataSource datasource1 = new JsonDataSource(new String(Files.readAllBytes(Paths.get(dataFile1)), StandardCharsets.UTF_8));
- workbook.addDataSource("ds1", datasource1);
- boolean page = false;
- if (page) {
- workbook.getNames().add("TemplateOptions.PaginationMode", "true");
- for (IWorksheet worksheet : workbook.getWorksheets()) {
- worksheet.getPageSetup().setPaperSize(PaperSize.A2);
- worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
- }
- }
- workbook.processTemplate();
- workbook.save(rootPath + index + ".result.xlsx");
- }
- }
复制代码 |
|