From 2a6fecc46823ffbbba3011b047c93ab38e1a7abc Mon Sep 17 00:00:00 2001 From: liaochong Date: Sat, 21 Nov 2020 11:52:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E9=9A=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../github/liaochong/myexcel/core/AbstractExcelFactory.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 218db546..e3887037 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.github.liaochong myexcel - 3.9.9 + 3.9.10 jar myexcel diff --git a/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelFactory.java b/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelFactory.java index d4d52c3e..7bcc0725 100644 --- a/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelFactory.java +++ b/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelFactory.java @@ -54,6 +54,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.util.Units; import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFDataValidation; @@ -353,8 +354,12 @@ private void setImage(Td td, Sheet sheet) { int pictureIdx = workbook.addPicture(bytes, format); Drawing drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = createHelper.createClientAnchor(); + anchor.setDx1(isHssf ? 2 : Units.EMU_PER_PIXEL); + anchor.setDy1(isHssf ? 2 : Units.EMU_PER_PIXEL); anchor.setCol1(td.getCol()); anchor.setRow1(td.getRow()); + anchor.setCol2(td.getColBound()); + anchor.setRow2(td.getRowBound()); Picture pict = drawing.createPicture(anchor, pictureIdx); pict.resize(1, 1); } catch (IOException e) { From 47a46c25a48c2a419a6bbafbcb228109229ba9cf Mon Sep 17 00:00:00 2001 From: liaochong Date: Sat, 21 Nov 2020 14:11:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89ExcelBuilder=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/liaochong/myexcel/core/AbstractExcelBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelBuilder.java b/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelBuilder.java index e73ff6e6..f943da06 100644 --- a/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelBuilder.java +++ b/src/main/java/com/github/liaochong/myexcel/core/AbstractExcelBuilder.java @@ -37,7 +37,7 @@ public abstract class AbstractExcelBuilder implements ExcelBuilder { protected HtmlToExcelFactory htmlToExcelFactory = new HtmlToExcelFactory(); - AbstractExcelBuilder(Class templateHandlerClass) { + protected AbstractExcelBuilder(Class templateHandlerClass) { widthStrategy(WidthStrategy.COMPUTE_AUTO_WIDTH); this.templateHandler = ReflectUtil.newInstance(templateHandlerClass); }