Parcourir la source

Populate row height and is custom height fields

Thieu Pham il y a 9 ans
Parent
commit
76a6790545
2 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 5 0
      lib.go
  2. 3 1
      lib_test.go

+ 5 - 0
lib.go

@@ -562,6 +562,11 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File, sheet *Sheet) ([]*R
 		}
 
 		row.Hidden = rawrow.Hidden
+		height, err := strconv.ParseFloat(rawrow.Ht, 64)
+		if err == nil {
+			row.Height = height
+		}
+		row.isCustom = rawrow.CustomHeight
 		row.OutlineLevel = rawrow.OutlineLevel
 
 		insertColIndex = minCol

+ 3 - 1
lib_test.go

@@ -293,7 +293,7 @@ func (l *LibSuite) TestReadRowsFromSheet(c *C) {
   </sheetViews>
   <sheetFormatPr baseColWidth="10" defaultRowHeight="15"/>
   <sheetData>
-    <row r="1" spans="1:2">
+    <row r="1" spans="1:2" ht="123.45" customHeight="1">
       <c r="A1" t="s">
         <v>0</v>
       </c>
@@ -331,6 +331,8 @@ func (l *LibSuite) TestReadRowsFromSheet(c *C) {
 	row := rows[0]
 	c.Assert(row.Sheet, Equals, sheet)
 	c.Assert(len(row.Cells), Equals, 2)
+	c.Assert(row.Height, Equals, 123.45)
+	c.Assert(row.isCustom, Equals, true)
 	cell1 := row.Cells[0]
 	c.Assert(cell1.Value, Equals, "Foo")
 	cell2 := row.Cells[1]