diff --git a/fastexcel-writer/src/main/java/org/dhatim/fastexcel/Worksheet.java b/fastexcel-writer/src/main/java/org/dhatim/fastexcel/Worksheet.java index 32519d3c..b5799d31 100644 --- a/fastexcel-writer/src/main/java/org/dhatim/fastexcel/Worksheet.java +++ b/fastexcel-writer/src/main/java/org/dhatim/fastexcel/Worksheet.java @@ -785,8 +785,9 @@ private void writeCols(Writer w, int maxCol) throws IOException { } boolean isHidden = hiddenColumns.contains(c); boolean hasStyle = colStyles.containsKey(c); + boolean widthChanged = colWidths.containsKey(c) || maxWidth > DEFAULT_COL_WIDTH; int groupLevel = groupColums.get(c); - if (colWidths.containsKey(c) || isHidden || groupLevel!=0 || hasStyle) { + if (widthChanged || isHidden || groupLevel != 0 || hasStyle) { if (!started) { w.append(""); started = true; diff --git a/fastexcel-writer/src/test/java/org/dhatim/fastexcel/CorrectnessTest.java b/fastexcel-writer/src/test/java/org/dhatim/fastexcel/CorrectnessTest.java index afcb49d8..aa92fff3 100644 --- a/fastexcel-writer/src/test/java/org/dhatim/fastexcel/CorrectnessTest.java +++ b/fastexcel-writer/src/test/java/org/dhatim/fastexcel/CorrectnessTest.java @@ -699,6 +699,7 @@ void testColumnStyle() throws Exception { worksheet.style(1).bold().set(); worksheet.style(1).fillColor(Color.BLACK).set(); worksheet.style(1, 1).fillColor(Color.BLUE_GRAY).set(); + worksheet.value(1, 1, "test"); worksheet.style(2).format("dd/MM/yyyy").set(); @@ -706,6 +707,7 @@ void testColumnStyle() throws Exception { .style().horizontalAlignment("left").fontColor(Color.ALMOND) .set(); worksheet.style(3).horizontalAlignment("center").set(); + worksheet.value(3, 3, "long test, long test, long test"); worksheet.style(4) .borderColor(BorderSide.RIGHT, BLACK) @@ -748,7 +750,11 @@ void testColumnStyle() throws Exception { worksheet.style(12) .fillColor(Color.YELLOW) .set(new ConditionalFormattingExpressionRule("L1>1", false)); + + worksheet.value(4, 13, "not long"); + worksheet.value(4, 14, "not long long long long long"); }); } + }