|
|
@@ -342,6 +342,67 @@ func (l *LibSuite) TestReadRowsFromSheet(c *C) {
|
|
|
c.Assert(pane.YSplit, Equals, 1.0)
|
|
|
}
|
|
|
|
|
|
+func (l *LibSuite) TestReadRowsFromSheetWithMergeCells(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="3" uniqueCount="3">
|
|
|
+ <si>
|
|
|
+ <t>Value A</t>
|
|
|
+ </si>
|
|
|
+ <si>
|
|
|
+ <t>Value B</t>
|
|
|
+ </si>
|
|
|
+ <si>
|
|
|
+ <t>Value C</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:mx="http://schemas.microsoft.com/office/mac/excel/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
|
|
|
+ <sheetViews>
|
|
|
+ <sheetView workbookViewId="0"/>
|
|
|
+ </sheetViews>
|
|
|
+ <sheetFormatPr customHeight="1" defaultColWidth="17.29" defaultRowHeight="15.0"/>
|
|
|
+ <cols>
|
|
|
+ <col customWidth="1" min="1" max="6" width="14.43"/>
|
|
|
+ </cols>
|
|
|
+ <sheetData>
|
|
|
+ <row r="1" ht="15.75" customHeight="1">
|
|
|
+ <c r="A1" s="1" t="s">
|
|
|
+ <v>0</v>
|
|
|
+ </c>
|
|
|
+ </row>
|
|
|
+ <row r="2" ht="15.75" customHeight="1">
|
|
|
+ <c r="A2" s="1" t="s">
|
|
|
+ <v>1</v>
|
|
|
+ </c>
|
|
|
+ <c r="B2" s="1" t="s">
|
|
|
+ <v>2</v>
|
|
|
+ </c>
|
|
|
+ </row>
|
|
|
+ </sheetData>
|
|
|
+ <mergeCells count="1">
|
|
|
+ <mergeCell ref="A1:B1"/>
|
|
|
+ </mergeCells>
|
|
|
+ <drawing r:id="rId1"/>
|
|
|
+</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)
|
|
|
+ sheet := new(Sheet)
|
|
|
+ rows, _, _, _ := readRowsFromSheet(worksheet, file, sheet)
|
|
|
+ row := rows[0] //
|
|
|
+ cell1 := row.Cells[0]
|
|
|
+ c.Assert(cell1.HMerge, Equals, 1)
|
|
|
+ c.Assert(cell1.VMerge, Equals, 0)
|
|
|
+}
|
|
|
+
|
|
|
// An invalid value in the "r" attribute in a <row> was causing a panic
|
|
|
// in readRowsFromSheet. This test is a copy of TestReadRowsFromSheet,
|
|
|
// with the important difference of the value 1048576 below in <row r="1048576", which is
|