Skip to content

Commit a246db6

Browse files
committed
This closes qax-os#279, refs qax-os#1536, change the default point to pixels conversion factor
1 parent 08ba272 commit a246db6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

chart_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestChartSize(t *testing.T) {
9494
}
9595

9696
if !assert.Equal(t, 14, anchor.To.Col, "Expected 'to' column 14") ||
97-
!assert.Equal(t, 27, anchor.To.Row, "Expected 'to' row 27") {
97+
!assert.Equal(t, 29, anchor.To.Row, "Expected 'to' row 29") {
9898

9999
t.FailNow()
100100
}

rows.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ func (f *File) getRowHeight(sheet string, row int) int {
380380
return int(convertRowHeightToPixels(*v.Ht))
381381
}
382382
}
383+
if ws.SheetFormatPr != nil && ws.SheetFormatPr.DefaultRowHeight > 0 {
384+
return int(convertRowHeightToPixels(ws.SheetFormatPr.DefaultRowHeight))
385+
}
383386
// Optimization for when the row heights haven't changed.
384387
return int(defaultRowHeightPixels)
385388
}
@@ -390,7 +393,7 @@ func (f *File) getRowHeight(sheet string, row int) int {
390393
// height, err := f.GetRowHeight("Sheet1", 1)
391394
func (f *File) GetRowHeight(sheet string, row int) (float64, error) {
392395
if row < 1 {
393-
return defaultRowHeightPixels, newInvalidRowNumberError(row)
396+
return defaultRowHeight, newInvalidRowNumberError(row)
394397
}
395398
ht := defaultRowHeight
396399
ws, err := f.workSheetReader(sheet)
@@ -840,10 +843,8 @@ func (f *File) SetRowStyle(sheet string, start, end, styleID int) error {
840843
// cell from user's units to pixels. If the height hasn't been set by the user
841844
// we use the default value. If the row is hidden it has a value of zero.
842845
func convertRowHeightToPixels(height float64) float64 {
843-
var pixels float64
844846
if height == 0 {
845-
return pixels
847+
return 0
846848
}
847-
pixels = math.Ceil(4.0 / 3.0 * height)
848-
return pixels
849+
return math.Ceil(4.0 / 3.4 * height)
849850
}

xmlDrawing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const (
144144
pivotTableVersion = 3
145145
defaultPictureScale = 1.0
146146
defaultChartDimensionWidth = 480
147-
defaultChartDimensionHeight = 290
147+
defaultChartDimensionHeight = 260
148148
defaultChartLegendPosition = "bottom"
149149
defaultChartShowBlanksAs = "gap"
150150
defaultShapeSize = 160

0 commit comments

Comments
 (0)