Skip to content

Commit

Permalink
Added row height
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Fox committed Jun 2, 2015
1 parent 37c9921 commit ddcb055
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 10 additions & 3 deletions row.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions xmlWorksheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ddcb055

Please sign in to comment.