summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-05-07 16:12:51 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2018-05-07 16:12:51 +0800
commit38ad20efc11c1872c4e62a12617f0300c138b867 (patch)
tree7190083ed4fa8ddaa1ec3b9ecb260423451f3164 /excelize.go
parentbc451a78de32ccde2a4f6d0851ea6e41e45408f1 (diff)
save bytes on memory instead of string
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go11
1 files changed, 9 insertions, 2 deletions
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(`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`)
+ var newXmlns = []byte(`<worksheet xr:uid="{00000000-0001-0000-0000-000000000000}" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac xr xr2 xr3" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`)
+ 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