diff options
author | Ri Xu <xuri.me@gmail.com> | 2017-06-29 11:14:33 +0800 |
---|---|---|
committer | Ri Xu <xuri.me@gmail.com> | 2017-06-29 11:14:33 +0800 |
commit | 86466654e270786428540e34fd0a61e7d537a99c (patch) | |
tree | a54a14a9c6d3de0342d0f43b375e61c2b4aa8fcc /rows.go | |
parent | 14eca84073c05e7514634c0949785256295a7500 (diff) |
- 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
Diffstat (limited to 'rows.go')
-rw-r--r-- | rows.go | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -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{} |