Bugfix: read sheet name error, relate issue #137
Signed-off-by: Ri Xu <xuri.me@gmail.com>
This commit is contained in:
parent
b4ffa8ce48
commit
8077732dff
|
@ -80,7 +80,7 @@ func (f *File) setDefaultTimeStyle(sheet, axis string) {
|
||||||
// workSheetReader provides function to get the pointer to the structure after
|
// workSheetReader provides function to get the pointer to the structure after
|
||||||
// deserialization by given worksheet index.
|
// deserialization by given worksheet index.
|
||||||
func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
|
func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
|
||||||
name, ok := f.sheetMap[sheet]
|
name, ok := f.sheetMap[trimSheetName(sheet)]
|
||||||
if !ok {
|
if !ok {
|
||||||
name = "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
|
name = "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
|
||||||
}
|
}
|
||||||
|
|
10
rows.go
10
rows.go
|
@ -21,7 +21,10 @@ import (
|
||||||
func (f *File) GetRows(sheet string) [][]string {
|
func (f *File) GetRows(sheet string) [][]string {
|
||||||
xlsx := f.workSheetReader(sheet)
|
xlsx := f.workSheetReader(sheet)
|
||||||
rows := [][]string{}
|
rows := [][]string{}
|
||||||
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
|
name, ok := f.sheetMap[trimSheetName(sheet)]
|
||||||
|
if !ok {
|
||||||
|
return rows
|
||||||
|
}
|
||||||
if xlsx != nil {
|
if xlsx != nil {
|
||||||
output, _ := xml.Marshal(f.Sheet[name])
|
output, _ := xml.Marshal(f.Sheet[name])
|
||||||
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
||||||
|
@ -31,7 +34,7 @@ func (f *File) GetRows(sheet string) [][]string {
|
||||||
var inElement string
|
var inElement string
|
||||||
var r xlsxRow
|
var r xlsxRow
|
||||||
var row []string
|
var row []string
|
||||||
tr, tc := f.getTotalRowsCols(sheet)
|
tr, tc := f.getTotalRowsCols(name)
|
||||||
for i := 0; i < tr; i++ {
|
for i := 0; i < tr; i++ {
|
||||||
row = []string{}
|
row = []string{}
|
||||||
for j := 0; j <= tc; j++ {
|
for j := 0; j <= tc; j++ {
|
||||||
|
@ -66,8 +69,7 @@ func (f *File) GetRows(sheet string) [][]string {
|
||||||
|
|
||||||
// getTotalRowsCols provides a function to get total columns and rows in a
|
// getTotalRowsCols provides a function to get total columns and rows in a
|
||||||
// worksheet.
|
// worksheet.
|
||||||
func (f *File) getTotalRowsCols(sheet string) (int, int) {
|
func (f *File) getTotalRowsCols(name string) (int, int) {
|
||||||
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
|
|
||||||
decoder := xml.NewDecoder(strings.NewReader(f.readXML(name)))
|
decoder := xml.NewDecoder(strings.NewReader(f.readXML(name)))
|
||||||
var inElement string
|
var inElement string
|
||||||
var r xlsxRow
|
var r xlsxRow
|
||||||
|
|
Loading…
Reference in New Issue