summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2022-01-23 00:32:34 +0800
committerxuri <xuri.me@gmail.com>2022-01-23 00:48:26 +0800
commit3ee3c38f9c63de3782fad21aae9c05ee0530fc32 (patch)
tree153928b23d79d259f6030cd902c836162f84e345 /excelize.go
parent74f6ea94eae45c8fb89a23cc94802e57ce279a84 (diff)
Fix file corrupted in some cases, check file extension and format code
Fix file corrupted when save as in XLAM / XLSM / XLTM / XLTX extension in some case New exported error ErrWorkbookExt has been added, and check file extension on save the workbook Format source code with `gofumpt`
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/excelize.go b/excelize.go
index 6100ac4..2155f0a 100644
--- a/excelize.go
+++ b/excelize.go
@@ -327,7 +327,7 @@ func checkSheetR0(ws *xlsxWorksheet, sheetData *xlsxSheetData, r0 *xlsxRow) {
// addRels provides a function to add relationships by given XML path,
// relationship type, target and target mode.
func (f *File) addRels(relPath, relType, target, targetMode string) int {
- var uniqPart = map[string]string{
+ uniqPart := map[string]string{
SourceRelationshipSharedStrings: "/xl/sharedStrings.xml",
}
rels := f.relsReader(relPath)
@@ -434,7 +434,6 @@ func (f *File) AddVBAProject(bin string) error {
if path.Ext(bin) != ".bin" {
return ErrAddVBAProject
}
- f.setContentTypePartVBAProjectExtensions()
wb := f.relsReader(f.getWorkbookRelsPath())
wb.Lock()
defer wb.Unlock()
@@ -463,9 +462,9 @@ func (f *File) AddVBAProject(bin string) error {
return err
}
-// setContentTypePartVBAProjectExtensions provides a function to set the
-// content type for relationship parts and the main document part.
-func (f *File) setContentTypePartVBAProjectExtensions() {
+// setContentTypePartProjectExtensions provides a function to set the content
+// type for relationship parts and the main document part.
+func (f *File) setContentTypePartProjectExtensions(contentType string) {
var ok bool
content := f.contentTypesReader()
content.Lock()
@@ -477,7 +476,7 @@ func (f *File) setContentTypePartVBAProjectExtensions() {
}
for idx, o := range content.Overrides {
if o.PartName == "/xl/workbook.xml" {
- content.Overrides[idx].ContentType = ContentTypeMacro
+ content.Overrides[idx].ContentType = contentType
}
}
if !ok {