diff --git a/lib.go b/lib.go index 986b46f4..c417a204 100644 --- a/lib.go +++ b/lib.go @@ -94,8 +94,8 @@ type Border struct { // Fill is a high level structure intended to provide user access to // the contents of background and foreground color index within an Sheet. type Fill struct { - BgColorIndex string - FgColorIndex string + BgColorIndex string + FgColorIndex string } // File is a high level structure providing a slice of Sheet structs @@ -249,7 +249,7 @@ func makeRowFromSpan(spans string) *Row { return row } -// get the max column +// get the max column // return the cells of columns func makeRowFromRaw(rawrow xlsxRow) *Row { var upper int @@ -338,12 +338,14 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File) ([]*Row, int, int) rowno := 0 for _, rawcell := range rawrow.C { x, y, _ := getCoordsFromCellIDString(rawcell.R) - if y != 0 && rowno == 0{ + if y != 0 && rowno == 0 { rowno = y } - row.Cells[x].Value = getValueFromCellData(rawcell, reftable) - row.Cells[x].styleIndex = rawcell.S - row.Cells[x].styles = file.styles + if x < len(row.Cells) { + row.Cells[x].Value = getValueFromCellData(rawcell, reftable) + row.Cells[x].styleIndex = rawcell.S + row.Cells[x].styles = file.styles + } } rows[rowno] = row } diff --git a/style.go b/style.go index 408c4976..78e13997 100644 --- a/style.go +++ b/style.go @@ -80,6 +80,6 @@ type xlsxLine struct { type xlsxXf struct { ApplyBorder string `xml:"applyBorder,attr"` BorderId int `xml:"borderId,attr"` - ApplyFill string `xml:"applyFill,attr"` - FillId int `xml:"fillId,attr"` + ApplyFill string `xml:"applyFill,attr"` + FillId int `xml:"fillId,attr"` } diff --git a/workbook.go b/workbook.go index 58e3e248..2ba3a788 100644 --- a/workbook.go +++ b/workbook.go @@ -108,8 +108,13 @@ func getWorksheetFromSheet(sheet xlsxSheet, worksheets map[string]*zip.File) (*x var decoder *xml.Decoder var worksheet *xlsxWorksheet var error error + var sheetName string worksheet = new(xlsxWorksheet) - sheetName := fmt.Sprintf("sheet%s", sheet.Id[3:]) + if sheet.SheetId != "" { + sheetName = fmt.Sprintf("sheet%s", sheet.SheetId) + } else { + sheetName = fmt.Sprintf("sheet%s", sheet.Id) + } f := worksheets[sheetName] rc, error = f.Open() if error != nil {