diff --git a/pom.xml b/pom.xml
index ebb5a1a..ca5350b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,12 @@
1.12.2
+
+ org.springframework
+ spring-expression
+ 5.3.18
+
+
diff --git a/src/main/java/vin/vio/usepoitl/exec/ApplicationStartExec.java b/src/main/java/vin/vio/usepoitl/exec/ApplicationStartExec.java
index d3e31b5..a0673d6 100644
--- a/src/main/java/vin/vio/usepoitl/exec/ApplicationStartExec.java
+++ b/src/main/java/vin/vio/usepoitl/exec/ApplicationStartExec.java
@@ -8,20 +8,14 @@ import com.deepoove.poi.template.ElementTemplate;
import com.deepoove.poi.template.MetaTemplate;
import com.deepoove.poi.template.run.RunTemplate;
import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.xwpf.usermodel.XWPFRun;
-import org.apache.poi.xwpf.usermodel.XWPFTableCell;
-import org.apache.poi.xwpf.usermodel.XWPFTableRow;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.poi.xwpf.usermodel.*;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
-import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;
import vin.vio.usepoitl.model.TableData;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
@@ -65,32 +59,39 @@ public class ApplicationStartExec implements ApplicationListener list = allTemplate.getElementTemplates();
+ boolean onSameLine = false;
+
+ Pattern pattern = Pattern.compile("\\[(.*?)\\]");
log.info("=====all tag=====");
for (MetaTemplate metaTemplate : list) {
if (metaTemplate instanceof ElementTemplate ele) {
log.info(ele.getTagName());
- XWPFRun run = ((RunTemplate) ele).getRun();
- if (run.getParent() instanceof XWPFTableCell) {
- XWPFTableCell cell = (XWPFTableCell) run.getParent();
- XWPFTableRow row = cell.getTableRow();
- List cells = row.getTableCells();
- for (XWPFTableCell tableCell : cells) {
- String cellText = tableCell.getText();
- Pattern pattern = Pattern.compile("\\[(.*?)\\]");
- Matcher matcher = pattern.matcher(cellText);
- while (matcher.find()) {
- String colTag = matcher.group(1);
- log.info("colTag {} {}", ele.getTagName(),colTag);
- }
+ if (!"table".equals(ele.getTagName())) {
+ continue;
+ }
+ }
+
+ if (metaTemplate instanceof RunTemplate runTemplate) {
+ XWPFRun run = runTemplate.getRun();
+ XWPFTableCell tagCell = (XWPFTableCell) ((XWPFParagraph) run.getParent()).getBody();
+ XWPFTable table = tagCell.getTableRow().getTable();
+ int templateRowIndex = getTemplateRowIndex(tagCell, onSameLine);
+
+ XWPFTableRow row = table.getRow(templateRowIndex);
+ for (XWPFTableCell cell : row.getTableCells()) {
+ String text = cell.getText();
+
+ Matcher matcher = pattern.matcher(text);
+ while (matcher.find()) {
+ String colTag = matcher.group(1);
+ log.info("colTag {}", colTag);
}
}
-
}
}
log.info("=====all tag=====END");
-
- LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
+ LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy(onSameLine);
Configure config = Configure.builder()
.bind("table", policy).build();
@@ -105,12 +106,12 @@ public class ApplicationStartExec implements ApplicationListener rows = row.getTable().getRows();
+ return rows.indexOf(row);
+ }
}