diff --git a/chart_test.go b/chart_test.go index f57cb4c8..ba17dbd6 100644 --- a/chart_test.go +++ b/chart_test.go @@ -94,7 +94,7 @@ func TestChartSize(t *testing.T) { } if !assert.Equal(t, 14, anchor.To.Col, "Expected 'to' column 14") || - !assert.Equal(t, 27, anchor.To.Row, "Expected 'to' row 27") { + !assert.Equal(t, 29, anchor.To.Row, "Expected 'to' row 29") { t.FailNow() } diff --git a/rows.go b/rows.go index c08a56d5..60b74b3a 100644 --- a/rows.go +++ b/rows.go @@ -380,6 +380,9 @@ func (f *File) getRowHeight(sheet string, row int) int { return int(convertRowHeightToPixels(*v.Ht)) } } + if ws.SheetFormatPr != nil && ws.SheetFormatPr.DefaultRowHeight > 0 { + return int(convertRowHeightToPixels(ws.SheetFormatPr.DefaultRowHeight)) + } // Optimization for when the row heights haven't changed. return int(defaultRowHeightPixels) } @@ -390,7 +393,7 @@ func (f *File) getRowHeight(sheet string, row int) int { // height, err := f.GetRowHeight("Sheet1", 1) func (f *File) GetRowHeight(sheet string, row int) (float64, error) { if row < 1 { - return defaultRowHeightPixels, newInvalidRowNumberError(row) + return defaultRowHeight, newInvalidRowNumberError(row) } ht := defaultRowHeight ws, err := f.workSheetReader(sheet) @@ -840,10 +843,8 @@ func (f *File) SetRowStyle(sheet string, start, end, styleID int) error { // cell from user's units to pixels. If the height hasn't been set by the user // we use the default value. If the row is hidden it has a value of zero. func convertRowHeightToPixels(height float64) float64 { - var pixels float64 if height == 0 { - return pixels + return 0 } - pixels = math.Ceil(4.0 / 3.0 * height) - return pixels + return math.Ceil(4.0 / 3.4 * height) } diff --git a/xmlDrawing.go b/xmlDrawing.go index 9e7c48ea..dae3bcc3 100644 --- a/xmlDrawing.go +++ b/xmlDrawing.go @@ -144,7 +144,7 @@ const ( pivotTableVersion = 3 defaultPictureScale = 1.0 defaultChartDimensionWidth = 480 - defaultChartDimensionHeight = 290 + defaultChartDimensionHeight = 260 defaultChartLegendPosition = "bottom" defaultChartShowBlanksAs = "gap" defaultShapeSize = 160