From 86466654e270786428540e34fd0a61e7d537a99c Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Thu, 29 Jun 2017 11:14:33 +0800 Subject: - Unify the index row number index of functions `SetRowHeight()` and `GetRowHeight()` relate issue #68; - Unify the return value data type of functions `SetColWidth()` and `GetColWidth()`; - go test updated --- rows.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'rows.go') diff --git a/rows.go b/rows.go index a913b7a..0dac853 100644 --- a/rows.go +++ b/rows.go @@ -116,10 +116,36 @@ func (f *File) SetRowHeight(sheet string, rowIndex int, height float64) { rows := rowIndex + 1 cells := 0 completeRow(xlsx, rows, cells) - xlsx.SheetData.Row[rowIndex].Ht = strconv.FormatFloat(height, 'f', -1, 64) + xlsx.SheetData.Row[rowIndex].Ht = height xlsx.SheetData.Row[rowIndex].CustomHeight = true } +// getRowHeight provides function to get row height in pixels by given sheet +// name and row index. +func (f *File) getRowHeight(sheet string, row int) int { + xlsx := f.workSheetReader(sheet) + for _, v := range xlsx.SheetData.Row { + if v.R == row+1 && v.Ht != 0 { + return int(convertRowHeightToPixels(v.Ht)) + } + } + // Optimisation for when the row heights haven't changed. + return int(defaultRowHeightPixels) +} + +// GetRowHeight provides function to get row height by given worksheet name and +// row index. +func (f *File) GetRowHeight(sheet string, row int) float64 { + xlsx := f.workSheetReader(sheet) + for _, v := range xlsx.SheetData.Row { + if v.R == row+1 && v.Ht != 0 { + return v.Ht + } + } + // Optimisation for when the row heights haven't changed. + return defaultRowHeightPixels +} + // readXMLSST read xmlSST simple function. func readXMLSST(f *File) (*xlsxSST, error) { shardStrings := xlsxSST{} -- cgit v1.2.1