From a26fbe729817216bcf53b13945fe6300caa89997 Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期五, 04 八月 2023 15:12:21 +0800
Subject: [PATCH] 打印模板 打印流程审批意见

---
 src/main/java/com/product/print/util/DynamicTableRenderPolicy.java |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/product/print/util/DynamicTableRenderPolicy.java b/src/main/java/com/product/print/util/DynamicTableRenderPolicy.java
index a8179d1..b7f20e3 100644
--- a/src/main/java/com/product/print/util/DynamicTableRenderPolicy.java
+++ b/src/main/java/com/product/print/util/DynamicTableRenderPolicy.java
@@ -9,6 +9,7 @@
 import com.product.print.config.CmnCode;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.xwpf.usermodel.*;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -133,9 +134,7 @@
 				XWPFTableCell cell;
 				//鍒ゆ柇row涓j涓崟鍏冩牸鏄惁瀛樺湪
 				if (row.getTableCells().size() > j) {
-					cell = row.getTableCells().get(j);
-					//娓呯┖鍗曞厓鏍煎唴瀹�
-					cell.removeParagraph(0);
+					cell = row.getCell(j);
 				} else {
 					cell = row.createCell();
 				}
@@ -149,8 +148,21 @@
 				if (value == null) {
 					value = "";
 				}
-				//璁剧疆鍗曞厓鏍肩殑鍊�
+				String text = cell.getText();
+				//鍒犻櫎鍗曞厓鏍间腑鐨勬棫鍐呭
+				if (!StringUtils.isEmpty(text)) {
+					List<XWPFParagraph> paragraphs = cell.getParagraphs();
+					if(paragraphs.size()>1){
+						cell.removeParagraph(1);
+					}
+					List<XWPFRun> runs = paragraphs.get(0).getRuns();
+					//娓呯┖鏂囧瓧
+					for (int k = 0; k < runs.size(); k++) {
+						runs.get(k).setText("", 0);
+					}
+				}
 				cell.setText(value.toString());
+
 			}
 		}
 		//鍒犻櫎璧峰琛�
@@ -248,6 +260,7 @@
 			}
 			copyTableCell(cell1, cell2);
 		}
+
 	}
 
 	/**

--
Gitblit v1.9.2