From 38ad20efc11c1872c4e62a12617f0300c138b867 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 7 May 2018 16:12:51 +0800 Subject: save bytes on memory instead of string --- excelize.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'excelize.go') diff --git a/excelize.go b/excelize.go index 0b1e410..31fa370 100644 --- a/excelize.go +++ b/excelize.go @@ -23,7 +23,7 @@ type File struct { Styles *xlsxStyleSheet WorkBook *xlsxWorkbook WorkBookRels *xlsxWorkbookRels - XLSX map[string]string + XLSX map[string][]byte } // OpenFile take the name of an XLSX file and returns a populated XLSX file @@ -88,7 +88,7 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet { } if f.Sheet[name] == nil { var xlsx xlsxWorksheet - xml.Unmarshal([]byte(f.readXML(name)), &xlsx) + xml.Unmarshal(f.readXML(name), &xlsx) if f.checked == nil { f.checked = make(map[string]bool) } @@ -141,6 +141,13 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string { return workbookMarshal } +func replaceWorkSheetsRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte { + var oldXmlns = []byte(``) + var newXmlns = []byte(``) + workbookMarshal = bytes.Replace(workbookMarshal, oldXmlns, newXmlns, -1) + return workbookMarshal +} + // UpdateLinkedValue fix linked values within a spreadsheet are not updating in // Office Excel 2007 and 2010. This function will be remove value tag when met a // cell have a linked value. Reference -- cgit v1.2.1