summaryrefslogtreecommitdiff
path: root/rows.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-06-28 00:02:32 +0800
committerxuri <xuri.me@gmail.com>2020-06-28 00:02:32 +0800
commit1cbb05d4977fc1c03fa37d704118fd9c722e487d (patch)
tree9f548ea7d07cc8a007fda12b4cd2ea8f7a0155cd /rows.go
parent48f19f60aa3e162146a9dc4edf7b4c8cf687ec26 (diff)
GetCols support the row element without r attribute in the worksheet
Diffstat (limited to 'rows.go')
-rw-r--r--rows.go20
1 files changed, 8 insertions, 12 deletions
diff --git a/rows.go b/rows.go
index 38c1ecc..b89d916 100644
--- a/rows.go
+++ b/rows.go
@@ -32,7 +32,7 @@ import (
// }
// for _, row := range rows {
// for _, colCell := range row {
-// fmt.Println(colCell, "\t")
+// fmt.Print(colCell, "\t")
// }
// fmt.Println()
// }
@@ -111,6 +111,7 @@ func (rows *Rows) Columns() ([]string, error) {
}
}
if inElement == "c" {
+ cellCol++
colCell := xlsxC{}
_ = rows.decoder.DecodeElement(&colCell, &startElement)
if colCell.R != "" {
@@ -118,8 +119,6 @@ func (rows *Rows) Columns() ([]string, error) {
if err != nil {
return columns, err
}
- } else {
- cellCol++
}
blank := cellCol - len(columns)
for i := 1; i < blank; i++ {
@@ -177,10 +176,10 @@ func (f *File) Rows(sheet string) (*Rows, error) {
f.saveFileList(name, replaceRelationshipsNameSpaceBytes(output))
}
var (
- err error
- inElement string
- row, curRow int
- rows Rows
+ err error
+ inElement string
+ row int
+ rows Rows
)
decoder := f.xmlNewDecoder(bytes.NewReader(f.readXML(name)))
for {
@@ -192,18 +191,15 @@ func (f *File) Rows(sheet string) (*Rows, error) {
case xml.StartElement:
inElement = startElement.Name.Local
if inElement == "row" {
+ row++
for _, attr := range startElement.Attr {
if attr.Name.Local == "r" {
- curRow, err = strconv.Atoi(attr.Value)
+ row, err = strconv.Atoi(attr.Value)
if err != nil {
return &rows, err
}
- row = curRow
}
}
- if len(startElement.Attr) == 0 {
- row++
- }
rows.totalRow = row
}
default: