Update comments for the xmlNewDecoder (#542)

formula
match-meng 5 years ago committed by xuri
parent 4249dad8ea
commit 7358dca436

@ -66,7 +66,7 @@ func OpenFile(filename string) (*File, error) {
return f, nil return f, nil
} }
// object builder // newFile is object builder
func newFile() *File { func newFile() *File {
return &File{ return &File{
checked: make(map[string]bool), checked: make(map[string]bool),
@ -117,10 +117,11 @@ func OpenReader(r io.Reader) (*File, error) {
return f, nil return f, nil
} }
// CharsetTranscoder Set user defined codepage transcoder function for open XLSX from non UTF-8 encoding // CharsetTranscoder Set user defined codepage transcoder function for open
// XLSX from non UTF-8 encoding.
func (f *File) CharsetTranscoder(fn charsetTranscoderFn) *File { f.CharsetReader = fn; return f } func (f *File) CharsetTranscoder(fn charsetTranscoderFn) *File { f.CharsetReader = fn; return f }
// Creates new XML decoder with charset reader // Creates new XML decoder with charset reader.
func (f *File) xmlNewDecoder(rdr io.Reader) (ret *xml.Decoder) { func (f *File) xmlNewDecoder(rdr io.Reader) (ret *xml.Decoder) {
ret = xml.NewDecoder(rdr) ret = xml.NewDecoder(rdr)
ret.CharsetReader = f.CharsetReader ret.CharsetReader = f.CharsetReader

@ -283,7 +283,10 @@ func (xlsx *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) {
case "s": case "s":
xlsxSI := 0 xlsxSI := 0
xlsxSI, _ = strconv.Atoi(xlsx.V) xlsxSI, _ = strconv.Atoi(xlsx.V)
return f.formattedValue(xlsx.S, d.SI[xlsxSI].String()), nil if len(d.SI) > xlsxSI {
return f.formattedValue(xlsx.S, d.SI[xlsxSI].String()), nil
}
return f.formattedValue(xlsx.S, xlsx.V), nil
case "str": case "str":
return f.formattedValue(xlsx.S, xlsx.V), nil return f.formattedValue(xlsx.S, xlsx.V), nil
case "inlineStr": case "inlineStr":

@ -163,7 +163,7 @@ func (f *File) setContentTypes(index int) {
func (f *File) setSheet(index int, name string) { func (f *File) setSheet(index int, name string) {
xlsx := xlsxWorksheet{ xlsx := xlsxWorksheet{
Dimension: &xlsxDimension{Ref: "A1"}, Dimension: &xlsxDimension{Ref: "A1"},
SheetViews: xlsxSheetViews{ SheetViews: &xlsxSheetViews{
SheetView: []xlsxSheetView{{WorkbookViewID: 0}}, SheetView: []xlsxSheetView{{WorkbookViewID: 0}},
}, },
} }

@ -18,7 +18,7 @@ type xlsxWorksheet struct {
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main worksheet"` XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main worksheet"`
SheetPr *xlsxSheetPr `xml:"sheetPr"` SheetPr *xlsxSheetPr `xml:"sheetPr"`
Dimension *xlsxDimension `xml:"dimension"` Dimension *xlsxDimension `xml:"dimension"`
SheetViews xlsxSheetViews `xml:"sheetViews"` SheetViews *xlsxSheetViews `xml:"sheetViews"`
SheetFormatPr *xlsxSheetFormatPr `xml:"sheetFormatPr"` SheetFormatPr *xlsxSheetFormatPr `xml:"sheetFormatPr"`
Cols *xlsxCols `xml:"cols"` Cols *xlsxCols `xml:"cols"`
SheetData xlsxSheetData `xml:"sheetData"` SheetData xlsxSheetData `xml:"sheetData"`

Loading…
Cancel
Save