Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add correction to row height and column width obtained in SheetUtil methods #941

Merged
merged 3 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenXmlFormats/Drawing/Chart/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8943,7 +8943,7 @@ internal void Write(StreamWriter sw, string nodeName)
XmlHelper.WriteAttribute(sw, "formatCode", this.formatCode);
sw.Write(">");
if (this.v != null)
sw.Write(string.Format("<c:v>{0}</c:v>", this.v.ToString(CultureInfo.InvariantCulture));
sw.Write(string.Format("<c:v>{0}</c:v>", this.v.ToString(CultureInfo.InvariantCulture)));
sw.Write(string.Format("</c:{0}>", nodeName));
}

Expand Down
8 changes: 5 additions & 3 deletions main/SS/Util/SheetUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private static int GetNumberOfRowsInMergedRegion(ICell cell)
{
if (region.IsInRange(cell.RowIndex, cell.ColumnIndex))
{
return 1 + region.LastColumn - region.FirstColumn;
return 1 + region.LastRow - region.FirstRow;
}
}

Expand All @@ -364,7 +364,8 @@ private static int GetNumberOfRowsInMergedRegion(ICell cell)

private static double GetCellConetntHeight(double actualHeight, int numberOfRowsInMergedRegion)
{
return Math.Max(-1, actualHeight / numberOfRowsInMergedRegion);
var correction = 1.1;
return Math.Max(-1, actualHeight / numberOfRowsInMergedRegion * correction);
}

private static string GetCellStringValue(ICell cell)
Expand Down Expand Up @@ -544,7 +545,8 @@ private static double GetCellWidth(int defaultCharWidth, int colspan,
// entireWidth accounts for leading spaces which is excluded from bounds.getWidth()
//double frameWidth = bounds.getX() + bounds.getWidth();
//width = Math.max(width, ((frameWidth / colspan) / defaultCharWidth) + style.getIndention());
width = Math.Max(width, (actualWidth / colspan / defaultCharWidth) + cell.CellStyle.Indention);
var correction = 1.1;
width = Math.Max(width, (actualWidth / colspan / defaultCharWidth * correction) + cell.CellStyle.Indention);
return width;
}

Expand Down