diff options
author | Ri Xu <xuri.me@gmail.com> | 2017-02-06 09:46:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-06 09:46:40 +0800 |
commit | 94dc0da329a645ed8956e9d688cdc722ddd79f23 (patch) | |
tree | 29f11bd093fb354032f8f15fb679f49c77a1a8ac /rows.go | |
parent | a1060e779ee295e9871e2fbe9148d8d9dc72a379 (diff) | |
parent | 8ce12b60b8a37ce6d3bd0bcee360393d52d4d0eb (diff) |
Merge pull request #18 from nikolassilva/master
Add SetRowHeight function
Diffstat (limited to 'rows.go')
-rw-r--r-- | rows.go | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -36,6 +36,34 @@ func (f *File) GetRows(sheet string) [][]string { return r } +// SetRowHeight provides a function to set the height of a single row. +// For example: +// +// xlsx := excelize.CreateFile() +// xlsx.SetRowHeight("Sheet1", 0, 50) +// err := xlsx.Save() +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// +func (f *File) SetRowHeight(sheet string, rowIndex int, height float64) { + xlsx := xlsxWorksheet{} + name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml" + xml.Unmarshal([]byte(f.readXML(name)), &xlsx) + + rows := rowIndex + 1 + cells := 0 + + xlsx = completeRow(xlsx, rows, cells) + + xlsx.SheetData.Row[rowIndex].Ht = strconv.FormatFloat(height, 'f', -1, 64) + xlsx.SheetData.Row[rowIndex].CustomHeight = true + + output, _ := xml.Marshal(xlsx) + f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output))) +} + // readXMLSST read xmlSST simple function. func readXMLSST(f *File) (xlsxSST, error) { shardStrings := xlsxSST{} |