Browse Source

Added row height

Colin Fox 10 years ago
parent
commit
ddcb0555bf
3 changed files with 20 additions and 7 deletions
  1. 10 3
      row.go
  2. 4 0
      sheet.go
  3. 6 4
      xmlWorksheet.go

+ 10 - 3
row.go

@@ -1,9 +1,16 @@
 package xlsx
 
 type Row struct {
-	Cells  []*Cell
-	Hidden bool
-	Sheet  *Sheet
+	Cells    []*Cell
+	Hidden   bool
+	Sheet    *Sheet
+	Height   float64
+	IsCustom bool
+}
+
+func (r *Row) SetHeightCM(ht float64) {
+	r.Height = ht * 28.3464567 // Convert CM to postscript points
+	r.IsCustom = true
 }
 
 func (r *Row) AddCell() *Cell {

+ 4 - 0
sheet.go

@@ -110,6 +110,10 @@ func (s *Sheet) makeXLSXSheet(refTable *RefTable, styles *xlsxStyleSheet) *xlsxW
 		}
 		xRow := xlsxRow{}
 		xRow.R = r + 1
+		if row.IsCustom {
+			xRow.CustomHeight = true
+			xRow.Ht = fmt.Sprintf("%g", row.Height)
+		}
 		for c, cell := range row.Cells {
 			style := cell.GetStyle()
 			if style != nil {

+ 6 - 4
xmlWorksheet.go

@@ -222,10 +222,12 @@ type xlsxSheetData struct {
 // currently I have not checked it for completeness - it does as much
 // as I need.
 type xlsxRow struct {
-	R      int     `xml:"r,attr"`
-	Spans  string  `xml:"spans,attr,omitempty"`
-	Hidden bool    `xml:"hidden,attr,omitempty"`
-	C      []xlsxC `xml:"c"`
+	R            int     `xml:"r,attr"`
+	Spans        string  `xml:"spans,attr,omitempty"`
+	Hidden       bool    `xml:"hidden,attr,omitempty"`
+	C            []xlsxC `xml:"c"`
+	Ht           string  `xml:"ht,attr,omitempty"`
+	CustomHeight bool    `xml:"customHeight,attr,omitempty"`
 }
 
 type xlsxMergeCell struct {