From 8cd10d947d29215ed7623cf3270614869e15ece0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?AdrianParn=C3=A9us?= Date: Tue, 29 Sep 2026 16:05:40 +0200 Subject: [PATCH] fixed issue where show column stripes would remove border. --- src/EPPlus.Export.Pdf.Tests/PdfTests.cs | 9 ++++++++ .../PdfExport/TextMapping/PdfTextMap.cs | 22 +++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/EPPlus.Export.Pdf.Tests/PdfTests.cs b/src/EPPlus.Export.Pdf.Tests/PdfTests.cs index 893cec994..806ec1df2 100644 --- a/src/EPPlus.Export.Pdf.Tests/PdfTests.cs +++ b/src/EPPlus.Export.Pdf.Tests/PdfTests.cs @@ -1127,5 +1127,14 @@ public void PngTransparentTest() string path = _pdfPath + "Allsvenskan2001.pdf"; ws.SaveAsPdf(path); } + + [TestMethod] + public void TableDxfStyleTest() + { + using var p = OpenTemplatePackage("TableDxfStylePdf1.xlsx"); + var ws = p.Workbook.Worksheets[0]; + string path = _pdfPath + "TableDxfStylePdf1.pdf"; + ws.SaveAsPdf(path); + } } } diff --git a/src/EPPlus/Export/PdfExport/TextMapping/PdfTextMap.cs b/src/EPPlus/Export/PdfExport/TextMapping/PdfTextMap.cs index 4d371ca36..139b985fa 100644 --- a/src/EPPlus/Export/PdfExport/TextMapping/PdfTextMap.cs +++ b/src/EPPlus/Export/PdfExport/TextMapping/PdfTextMap.cs @@ -878,21 +878,19 @@ internal static ExcelDxfBorderItem GetTopBorderItem(ExcelRangeBase cell, ExcelBo { if (table.ShowColumnStripes && (tableCol & 1) == 0) { - if (cell._fromRow - ts > range._fromRow && cell._fromRow < range._toRow) - { top = tableStyle.FirstColumnStripe.Style.Border.Horizontal; elementOrder = TableEdgeOrder.FirstColumnStripe; } - else if (cell._fromRow <= range._toRow) - { top = null; } - else - { top = tableStyle.FirstColumnStripe.Style.Border.Top; elementOrder = TableEdgeOrder.FirstColumnStripe; } + var band = tableStyle.FirstColumnStripe.Style.Border; + if (tableRow == 0) + { if (band.Top.HasValue) { top = band.Top; elementOrder = TableEdgeOrder.FirstColumnStripe; } } + else if (band.Horizontal.HasValue) + { top = band.Horizontal; elementOrder = TableEdgeOrder.FirstColumnStripe; } } if (table.ShowColumnStripes && (tableCol & 1) != 0) { - if (cell._fromRow + ts > range._fromRow && cell._fromRow < range._toRow) - { top = tableStyle.SecondColumnStripe.Style.Border.Horizontal; elementOrder = TableEdgeOrder.SecondColumnStripe; } - else if (cell._fromRow <= range._toRow) - { top = null; } - else - { top = tableStyle.SecondColumnStripe.Style.Border.Top; elementOrder = TableEdgeOrder.SecondColumnStripe; } + var band = tableStyle.SecondColumnStripe.Style.Border; + if (tableRow == 0) + { if (band.Top.HasValue) { top = band.Top; elementOrder = TableEdgeOrder.SecondColumnStripe; } } + else if (band.Horizontal.HasValue) + { top = band.Horizontal; elementOrder = TableEdgeOrder.SecondColumnStripe; } } if (table.ShowRowStripes && tableStyle.FirstRowStripe.Style.Border.Top.HasValue && (tableRow & 1) != 0) { top = tableStyle.FirstRowStripe.Style.Border.Top; elementOrder = TableEdgeOrder.FirstRowStripe; }