Просмотр исходного кода

Convert TestReadRowsFromSheetWithLeadingEmptyRows

Geoffrey J. Teale 11 лет назад
Родитель
Сommit
a012c8183a
1 измененных файлов с 46 добавлено и 55 удалено
  1. 46 55
      lib_test.go

+ 46 - 55
lib_test.go

@@ -398,61 +398,52 @@ func (l *LibSuite) TestReadRowsFromSheet(c *C) {
 	c.Assert(cell2.String(), Equals, "Bar")
 }
 
-// func (l *LibSuite) TestReadRowsFromSheetWithLeadingEmptyRows(c *C) {
-// 	var sharedstringsXML = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-// <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="2" uniqueCount="2"><si><t>ABC</t></si><si><t>DEF</t></si></sst>`)
-// 	var sheetxml = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-// <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">
-//   <dimension ref="A4:A5"/>
-//   <sheetViews>
-//     <sheetView tabSelected="1" workbookViewId="0">
-//       <selection activeCell="A2" sqref="A2"/>
-//     </sheetView>
-//   </sheetViews>
-//   <sheetFormatPr baseColWidth="10" defaultRowHeight="15" x14ac:dyDescent="0"/>
-//   <sheetData>
-//     <row r="4" spans="1:1">
-//       <c r="A4" t="s">
-//         <v>0</v>
-//       </c>
-//     </row>
-//     <row r="5" spans="1:1">
-//       <c r="A5" t="s">
-//         <v>1</v>
-//       </c>
-//     </row>
-//   </sheetData>
-//   <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/>
-//   <pageSetup paperSize="9" orientation="portrait" horizontalDpi="4294967292" verticalDpi="4294967292"/>
-//   <extLst>
-//     <ext uri="{64002731-A6B0-56B0-2670-7721B7C09600}" xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main">
-//       <mx:PLV Mode="0" OnePage="0" WScale="0"/>
-//     </ext>
-//   </extLst>
-// </worksheet>
-// `)
-// 	worksheet := new(xlsxWorksheet)
-// 	err := xml.NewDecoder(sheetxml).Decode(worksheet)
-// 	if err != nil {
-// 		t.Error(err.Error())
-// 		return
-// 	}
-// 	sst := new(xlsxSST)
-// 	err = xml.NewDecoder(sharedstringsXML).Decode(sst)
-// 	if err != nil {
-// 		t.Error(err.Error())
-// 		return
-// 	}
-// 	file := new(File)
-// 	file.referenceTable = MakeSharedStringRefTable(sst)
-// 	rows, maxCols, maxRows := readRowsFromSheet(worksheet, file)
-// 	if maxRows != 2 {
-// 		t.Error("Expected maxRows == 2, got ", strconv.Itoa(len(rows)))
-// 	}
-// 	if maxCols != 1 {
-// 		t.Error("Expected maxCols == 1, got ", strconv.Itoa(maxCols))
-// 	}
-// }
+func (l *LibSuite) TestReadRowsFromSheetWithLeadingEmptyRows(c *C) {
+	var sharedstringsXML = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="2" uniqueCount="2"><si><t>ABC</t></si><si><t>DEF</t></si></sst>`)
+	var sheetxml = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">
+  <dimension ref="A4:A5"/>
+  <sheetViews>
+    <sheetView tabSelected="1" workbookViewId="0">
+      <selection activeCell="A2" sqref="A2"/>
+    </sheetView>
+  </sheetViews>
+  <sheetFormatPr baseColWidth="10" defaultRowHeight="15" x14ac:dyDescent="0"/>
+  <sheetData>
+    <row r="4" spans="1:1">
+      <c r="A4" t="s">
+        <v>0</v>
+      </c>
+    </row>
+    <row r="5" spans="1:1">
+      <c r="A5" t="s">
+        <v>1</v>
+      </c>
+    </row>
+  </sheetData>
+  <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/>
+  <pageSetup paperSize="9" orientation="portrait" horizontalDpi="4294967292" verticalDpi="4294967292"/>
+  <extLst>
+    <ext uri="{64002731-A6B0-56B0-2670-7721B7C09600}" xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main">
+      <mx:PLV Mode="0" OnePage="0" WScale="0"/>
+    </ext>
+  </extLst>
+</worksheet>
+`)
+	worksheet := new(xlsxWorksheet)
+	err := xml.NewDecoder(sheetxml).Decode(worksheet)
+	c.Assert(err, IsNil)
+	sst := new(xlsxSST)
+	err = xml.NewDecoder(sharedstringsXML).Decode(sst)
+	c.Assert(err, IsNil)
+
+	file := new(File)
+	file.referenceTable = MakeSharedStringRefTable(sst)
+	rows, maxCols, maxRows := readRowsFromSheet(worksheet, file)
+	c.Assert(maxRows, Equals, 2)
+	c.Assert(maxCols, Equals, 1)
+}
 
 // func (l *LibSuite) TestReadRowsFromSheetWithEmptyCells(c *C) {
 // 	var sharedstringsXML = bytes.NewBufferString(`