Skip to content

Commit

Permalink
报表引擎增加直接生成ExcelWorkbook对象的帮助函数
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Sep 19, 2024
1 parent eb8b4d6 commit 9e93950
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 63 deletions.
36 changes: 36 additions & 0 deletions nop-cli-core/src/main/java/io/nop/cli/commands/GenOrmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
import io.nop.core.resource.VirtualFileSystem;
import io.nop.core.resource.impl.FileResource;
import io.nop.core.resource.tpl.ITemplateOutput;
import io.nop.excel.model.ExcelCell;
import io.nop.excel.model.ExcelRow;
import io.nop.excel.model.ExcelSheet;
import io.nop.excel.model.ExcelTable;
import io.nop.excel.model.ExcelWorkbook;
import io.nop.orm.model.IEntityModel;
import io.nop.orm.model.OrmModel;
import io.nop.report.core.XptConstants;
import io.nop.report.core.engine.IReportEngine;
Expand All @@ -29,6 +34,7 @@

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GenOrmHelper {
Expand Down Expand Up @@ -57,6 +63,36 @@ public static void saveOrmToExcel(OrmModel ormModel, File outputFile, boolean du
output.generateToFile(outputFile, scope);
}

public static void addCatalog(ExcelWorkbook workbook, OrmModel ormModel) {
ExcelSheet sheet = workbook.getSheet("目录");
ExcelTable table = sheet.getTable();
List<? extends IEntityModel> tables = ormModel.getEntityModels();
int index = 1;
String styleId0 = table.getCell(1, 0).getStyleId();
String styleId = table.getCell(1, 1).getStyleId();
String styleId2 = table.getCell(1, 2).getStyleId();
String styleId3 = table.getCell(1,3).getStyleId();

for (IEntityModel entityModel : tables) {
ExcelRow row = table.makeRow(index++);
row.makeCell(0).setValue(index);
((ExcelCell) row.makeCell(0)).setStyleId(styleId0);

ExcelCell cell = (ExcelCell) row.makeCell(1);
cell.setValue(entityModel.getTableName());
cell.setLinkUrl("ref:" + entityModel.getTableName() + "!A1");
cell.setStyleId(styleId);

ExcelCell cell2 = (ExcelCell) row.makeCell(2);
cell2.setStyleId(styleId2);
cell2.setValue(entityModel.getDisplayName());

ExcelCell cell3 = (ExcelCell) row.makeCell(3);
cell3.setStyleId(styleId3);
cell3.setValue(entityModel.getComment());
}
}

private static IReportEngine newReportEngine() {
ReportEngine reportEngine = new ReportEngine();
Map<String, IReportRendererFactory> renderers = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion nop-demo/nop-quarkus-demo/build-native.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set GRAALVM_HOME=C:\Software\graalvm
set GRAALVM_HOME=C:\Software\graalvm2102
set JAVA_HOME=%GRAALVM_HOME%
set Path=%GRAALVM_HOME%\bin;%Path%
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" && mvn package -Dnative
Loading

0 comments on commit 9e93950

Please sign in to comment.