diff --git a/README.md b/README.md
index a91453a..c3a3b9e 100644
--- a/README.md
+++ b/README.md
@@ -107,6 +107,14 @@ word和sax读取的时候才使用,就不是必须的了,请手动引用,JSR303
true
+
+
+ org.apache.poi
+ ooxml-schemas
+ 1.3
+ true
+
+
org.hibernate
diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/ParseWord07.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/ParseWord07.java
index ba2de75..0f764e4 100644
--- a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/ParseWord07.java
+++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/ParseWord07.java
@@ -220,7 +220,6 @@ public class ParseWord07 {
if (listobj == null) {
parseThisRow(cells, map);
} else if (listobj instanceof ExcelListEntity) {
- table.removeRow(i);// 删除这一行
new ExcelEntityParse().parseNextRowAndAddRow(table, i, (ExcelListEntity) listobj);
i = i + ((ExcelListEntity) listobj).getList().size() - 1;//删除之后要往上挪一行,然后加上跳过新建的行数
} else {
diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java
index 4c92f51..9487e3c 100644
--- a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java
+++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java
@@ -158,6 +158,7 @@ public class ExcelEntityParse extends ExportBase {
* @param entity
*/
public void parseNextRowAndAddRow(XWPFTable table, int index, ExcelListEntity entity) {
+ table.removeRow(index);// 删除这一行
checkExcelParams(entity);
// 获取表头数据
Map titlemap = getTitleMap(table, index, entity.getHeadRows());
diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelMapParse.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelMapParse.java
index 6611a0b..e8d171f 100644
--- a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelMapParse.java
+++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelMapParse.java
@@ -1,33 +1,39 @@
/**
* Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package cn.afterturn.easypoi.word.parse.excel;
-import static cn.afterturn.easypoi.util.PoiElUtil.*;
-
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.Maps;
-import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import com.google.common.collect.Maps;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import cn.afterturn.easypoi.util.PoiWordStyleUtil;
-import cn.afterturn.easypoi.util.PoiPublicUtil;
+import static cn.afterturn.easypoi.util.PoiElUtil.EMPTY;
+import static cn.afterturn.easypoi.util.PoiElUtil.END_STR;
+import static cn.afterturn.easypoi.util.PoiElUtil.FOREACH;
+import static cn.afterturn.easypoi.util.PoiElUtil.FOREACH_AND_SHIFT;
+import static cn.afterturn.easypoi.util.PoiElUtil.FOREACH_NOT_CREATE;
+import static cn.afterturn.easypoi.util.PoiElUtil.START_STR;
+import static cn.afterturn.easypoi.util.PoiElUtil.eval;
/**
* 处理和生成Map 类型的数据变成表格
@@ -36,9 +42,11 @@ import cn.afterturn.easypoi.util.PoiPublicUtil;
*/
public final class ExcelMapParse {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExcelMapParse.class);
+
/**
* 解析参数行,获取参数列表
- *
+ *
* @author JueYue
* 2013-11-18
* @param currentRow
@@ -51,7 +59,7 @@ public final class ExcelMapParse {
for (int i = 0; i < cells.size(); i++) {
text = cells.get(i).getText();
params[i] = text == null ? ""
- : text.trim().replace(START_STR, EMPTY).replace(END_STR, EMPTY);
+ : text.trim().replace(START_STR, EMPTY).replace(END_STR, EMPTY);
}
return params;
}
@@ -69,27 +77,33 @@ public final class ExcelMapParse {
String listname = params[0];
boolean isCreate = !listname.contains(FOREACH_NOT_CREATE);
listname = listname.replace(FOREACH_NOT_CREATE, EMPTY).replace(FOREACH_AND_SHIFT, EMPTY)
- .replace(FOREACH, EMPTY).replace(START_STR, EMPTY);
+ .replace(FOREACH, EMPTY).replace(START_STR, EMPTY);
String[] keys = listname.replaceAll("\\s{1,}", " ").trim().split(" ");
params[0] = keys[1];
- table.removeRow(index);// 移除这一行
+ //保存这一行的样式是-后面好统一设置
+ List tempCellList = new ArrayList();
+ tempCellList.addAll(table.getRow(index).getTableCells());
+ int templateInde = index;
int cellIndex = 0;// 创建完成对象一行好像多了一个cell
Map tempMap = Maps.newHashMap();
+ LOGGER.debug("start for each data list :{}", list.size());
for (Object obj : list) {
currentRow = isCreate ? table.insertNewTableRow(index++) : table.getRow(index++);
tempMap.put("t", obj);
for (cellIndex = 0; cellIndex < currentRow.getTableCells().size(); cellIndex++) {
String val = eval(params[cellIndex], tempMap).toString();
currentRow.getTableCells().get(cellIndex).setText("");
- PoiPublicUtil.setWordText(
- currentRow.getTableCells().get(cellIndex).addParagraph().createRun(), val);
+ PoiWordStyleUtil.copyCellAndSetValue(tempCellList.get(cellIndex),
+ currentRow.getTableCells().get(cellIndex), val);
}
for (; cellIndex < params.length; cellIndex++) {
String val = eval(params[cellIndex], tempMap).toString();
- PoiPublicUtil.setWordText(currentRow.createCell().addParagraph().createRun(), val);
+ PoiWordStyleUtil.copyCellAndSetValue(tempCellList.get(cellIndex),
+ currentRow.createCell(), val);
}
}
+ table.removeRow(index);// 移除这一行
}
diff --git a/pom.xml b/pom.xml
index 2b34f2a..bf78adc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
3.0.2-SNAPSHOT
- 3.15
+ 3.16
2.9.1
16.0.1
3.2.1
@@ -84,6 +84,13 @@
${poi.version}
true
+
+
+ org.apache.poi
+ ooxml-schemas
+ 1.3
+ true
+