Skip to content

Commit

Permalink
Merge pull request #374 from JakKowalCzyk/fix-col-width
Browse files Browse the repository at this point in the history
Fixed auto column width adjustment
  • Loading branch information
ochedru authored Dec 20, 2023
2 parents f151196 + 481ba3d commit 659bddf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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("<cols>");
started = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,15 @@ 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();

worksheet.range(3, 3, 6, 3)
.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)
Expand Down Expand Up @@ -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");
});
}


}

0 comments on commit 659bddf

Please sign in to comment.