summaryrefslogtreecommitdiff
path: root/rows.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-02-06 09:46:40 +0800
committerGitHub <noreply@github.com>2017-02-06 09:46:40 +0800
commit94dc0da329a645ed8956e9d688cdc722ddd79f23 (patch)
tree29f11bd093fb354032f8f15fb679f49c77a1a8ac /rows.go
parenta1060e779ee295e9871e2fbe9148d8d9dc72a379 (diff)
parent8ce12b60b8a37ce6d3bd0bcee360393d52d4d0eb (diff)
Merge pull request #18 from nikolassilva/master
Add SetRowHeight function
Diffstat (limited to 'rows.go')
-rw-r--r--rows.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/rows.go b/rows.go
index 384ee7d..4e655b1 100644
--- a/rows.go
+++ b/rows.go
@@ -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{}