From e05867a033cabfa100e7c2b284e1f85fd4769c3c Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Thu, 29 Jun 2017 13:28:44 +0800 Subject: Function `GetCellValue()` performance improvement by avoid repeating deserialization, relate issue #70. --- excelize.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'excelize.go') diff --git a/excelize.go b/excelize.go index f8b938c..8e91fea 100644 --- a/excelize.go +++ b/excelize.go @@ -15,15 +15,16 @@ import ( // File define a populated XLSX file struct. type File struct { - checked map[string]bool - ContentTypes *xlsxTypes - Path string - Sheet map[string]*xlsxWorksheet - SheetCount int - Styles *xlsxStyleSheet - WorkBook *xlsxWorkbook - WorkBookRels *xlsxWorkbookRels - XLSX map[string]string + checked map[string]bool + ContentTypes *xlsxTypes + Path string + SharedStrings *xlsxSST + Sheet map[string]*xlsxWorksheet + SheetCount int + Styles *xlsxStyleSheet + WorkBook *xlsxWorkbook + WorkBookRels *xlsxWorkbookRels + XLSX map[string]string } // OpenFile take the name of an XLSX file and returns a populated XLSX file @@ -145,8 +146,7 @@ func (f *File) setDefaultTimeStyle(sheet, axis string) { // deserialization by given worksheet index. func (f *File) workSheetReader(sheet string) *xlsxWorksheet { name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml" - worksheet := f.Sheet[name] - if worksheet == nil { + if f.Sheet[name] == nil { var xlsx xlsxWorksheet xml.Unmarshal([]byte(f.readXML(name)), &xlsx) if f.checked == nil { @@ -159,9 +159,8 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet { f.checked[name] = true } f.Sheet[name] = &xlsx - worksheet = f.Sheet[name] } - return worksheet + return f.Sheet[name] } // SetCellInt provides function to set int type value of a cell by given -- cgit v1.2.1