Typo fix, rename exported constants, dependencies modules and copyright update

Rename exported constants `NameSpaceDublinCoreMetadataIntiative` to `NameSpaceDublinCoreMetadataInitiative`
This commit is contained in:
xuri 2022-01-09 00:20:42 +08:00
parent af5c4d00e8
commit 2245fccca0
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
62 changed files with 220 additions and 224 deletions

View File

@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2016-2021 The excelize Authors.
Copyright (c) 2016-2022 The excelize Authors.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -81,13 +81,13 @@ func (f *File) adjustRowDimensions(ws *xlsxWorksheet, row, offset int) {
for i := range ws.SheetData.Row {
r := &ws.SheetData.Row[i]
if newRow := r.R + offset; r.R >= row && newRow > 0 {
f.ajustSingleRowDimensions(r, newRow)
f.adjustSingleRowDimensions(r, newRow)
}
}
}
// ajustSingleRowDimensions provides a function to ajust single row dimensions.
func (f *File) ajustSingleRowDimensions(r *xlsxRow, num int) {
// adjustSingleRowDimensions provides a function to adjust single row dimensions.
func (f *File) adjustSingleRowDimensions(r *xlsxRow, num int) {
r.R = num
for i, col := range r.C {
colName, _, _ := SplitCellName(col.R)

View File

@ -48,7 +48,7 @@ func TestAdjustMergeCells(t *testing.T) {
// testing adjustMergeCells
var cases []struct {
lable string
label string
ws *xlsxWorksheet
dir adjustDirection
num int
@ -58,7 +58,7 @@ func TestAdjustMergeCells(t *testing.T) {
// testing insert
cases = []struct {
lable string
label string
ws *xlsxWorksheet
dir adjustDirection
num int
@ -66,7 +66,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect string
}{
{
lable: "insert row on ref",
label: "insert row on ref",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -82,7 +82,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect: "A3:B4",
},
{
lable: "insert row on bottom of ref",
label: "insert row on bottom of ref",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -98,7 +98,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect: "A2:B4",
},
{
lable: "insert column on the left",
label: "insert column on the left",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -116,12 +116,12 @@ func TestAdjustMergeCells(t *testing.T) {
}
for _, c := range cases {
assert.NoError(t, f.adjustMergeCells(c.ws, c.dir, c.num, 1))
assert.Equal(t, c.expect, c.ws.MergeCells.Cells[0].Ref, c.lable)
assert.Equal(t, c.expect, c.ws.MergeCells.Cells[0].Ref, c.label)
}
// testing delete
cases = []struct {
lable string
label string
ws *xlsxWorksheet
dir adjustDirection
num int
@ -129,7 +129,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect string
}{
{
lable: "delete row on top of ref",
label: "delete row on top of ref",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -145,7 +145,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect: "A2:B2",
},
{
lable: "delete row on bottom of ref",
label: "delete row on bottom of ref",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -161,7 +161,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect: "A2:B2",
},
{
lable: "delete column on the ref left",
label: "delete column on the ref left",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -177,7 +177,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect: "A2:A3",
},
{
lable: "delete column on the ref right",
label: "delete column on the ref right",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -195,12 +195,12 @@ func TestAdjustMergeCells(t *testing.T) {
}
for _, c := range cases {
assert.NoError(t, f.adjustMergeCells(c.ws, c.dir, c.num, -1))
assert.Equal(t, c.expect, c.ws.MergeCells.Cells[0].Ref, c.lable)
assert.Equal(t, c.expect, c.ws.MergeCells.Cells[0].Ref, c.label)
}
// testing delete one row/column
cases = []struct {
lable string
label string
ws *xlsxWorksheet
dir adjustDirection
num int
@ -208,7 +208,7 @@ func TestAdjustMergeCells(t *testing.T) {
expect string
}{
{
lable: "delete one row ref",
label: "delete one row ref",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -223,7 +223,7 @@ func TestAdjustMergeCells(t *testing.T) {
offset: -1,
},
{
lable: "delete one column ref",
label: "delete one column ref",
ws: &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
@ -240,7 +240,7 @@ func TestAdjustMergeCells(t *testing.T) {
}
for _, c := range cases {
assert.NoError(t, f.adjustMergeCells(c.ws, c.dir, c.num, -1))
assert.Equal(t, 0, len(c.ws.MergeCells.Cells), c.lable)
assert.Equal(t, 0, len(c.ws.MergeCells.Cells), c.label)
}
f = NewFile()

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -25,7 +25,7 @@ func (f *File) calcChainReader() *xlsxCalcChain {
if f.CalcChain == nil {
f.CalcChain = new(xlsxCalcChain)
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(dafaultXMLPathCalcChain)))).
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathCalcChain)))).
Decode(f.CalcChain); err != nil && err != io.EOF {
log.Printf("xml decode error: %s", err)
}
@ -39,7 +39,7 @@ func (f *File) calcChainReader() *xlsxCalcChain {
func (f *File) calcChainWriter() {
if f.CalcChain != nil && f.CalcChain.C != nil {
output, _ := xml.Marshal(f.CalcChain)
f.saveFileList(dafaultXMLPathCalcChain, output)
f.saveFileList(defaultXMLPathCalcChain, output)
}
}
@ -54,7 +54,7 @@ func (f *File) deleteCalcChain(index int, axis string) {
}
if len(calc.C) == 0 {
f.CalcChain = nil
f.Pkg.Delete(dafaultXMLPathCalcChain)
f.Pkg.Delete(defaultXMLPathCalcChain)
content := f.contentTypesReader()
content.Lock()
defer content.Unlock()

View File

@ -5,7 +5,7 @@ import "testing"
func TestCalcChainReader(t *testing.T) {
f := NewFile()
f.CalcChain = nil
f.Pkg.Store(dafaultXMLPathCalcChain, MacintoshCyrillicCharset)
f.Pkg.Store(defaultXMLPathCalcChain, MacintoshCyrillicCharset)
f.calcChainReader()
}

16
cell.go
View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -372,9 +372,9 @@ func (f *File) setCellString(value string) (t, v string, err error) {
func (f *File) sharedStringsLoader() (err error) {
f.Lock()
defer f.Unlock()
if path, ok := f.tempFiles.Load(dafaultXMLPathSharedStrings); ok {
f.Pkg.Store(dafaultXMLPathSharedStrings, f.readBytes(dafaultXMLPathSharedStrings))
f.tempFiles.Delete(dafaultXMLPathSharedStrings)
if path, ok := f.tempFiles.Load(defaultXMLPathSharedStrings); ok {
f.Pkg.Store(defaultXMLPathSharedStrings, f.readBytes(defaultXMLPathSharedStrings))
f.tempFiles.Delete(defaultXMLPathSharedStrings)
err = os.Remove(path.(string))
f.SharedStrings, f.sharedStringItemMap = nil, nil
}
@ -455,7 +455,7 @@ func (f *File) GetCellFormula(sheet, axis string) (string, error) {
return "", false, nil
}
if c.F.T == STCellFormulaTypeShared && c.F.Si != nil {
return getSharedForumula(x, *c.F.Si, c.R), true, nil
return getSharedFormula(x, *c.F.Si, c.R), true, nil
}
return c.F.Content, true, nil
})
@ -621,7 +621,7 @@ func (ws *xlsxWorksheet) countSharedFormula() (count int) {
}
// GetCellHyperLink provides a function to get cell hyperlink by given
// worksheet name and axis. Boolean type value link will be ture if the cell
// worksheet name and axis. Boolean type value link will be true if the cell
// has a hyperlink and the target is the address of the hyperlink. Otherwise,
// the value of link will be false and the value of the target will be a blank
// string. For example get hyperlink of Sheet1!H6:
@ -1232,7 +1232,7 @@ func parseSharedFormula(dCol, dRow int, orig []byte) (res string, start int) {
return
}
// getSharedForumula find a cell contains the same formula as another cell,
// getSharedFormula find a cell contains the same formula as another cell,
// the "shared" value can be used for the t attribute and the si attribute can
// be used to refer to the cell containing the formula. Two formulas are
// considered to be the same when their respective representations in
@ -1240,7 +1240,7 @@ func parseSharedFormula(dCol, dRow int, orig []byte) (res string, start int) {
//
// Note that this function not validate ref tag to check the cell if or not in
// allow area, and always return origin shared formula.
func getSharedForumula(ws *xlsxWorksheet, si int, axis string) string {
func getSharedFormula(ws *xlsxWorksheet, si int, axis string) string {
for _, r := range ws.SheetData.Row {
for _, c := range r.C {
if c.F != nil && c.F.Ref != "" && c.F.T == STCellFormulaTypeShared && c.F.Si != nil && *c.F.Si == si {

View File

@ -653,14 +653,14 @@ func TestFormattedValue2(t *testing.T) {
func TestSharedStringsError(t *testing.T) {
f, err := OpenFile(filepath.Join("test", "Book1.xlsx"), Options{UnzipXMLSizeLimit: 128})
assert.NoError(t, err)
f.tempFiles.Store(dafaultXMLPathSharedStrings, "")
f.tempFiles.Store(defaultXMLPathSharedStrings, "")
assert.Equal(t, "1", f.getFromStringItemMap(1))
// Test reload the file error on set cell cell and rich text. The error message was different between macOS and Windows.
err = f.SetCellValue("Sheet1", "A19", "A19")
assert.Error(t, err)
f.tempFiles.Store(dafaultXMLPathSharedStrings, "")
f.tempFiles.Store(defaultXMLPathSharedStrings, "")
err = f.SetCellRichText("Sheet1", "A19", []RichTextRun{})
assert.Error(t, err)

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

2
col.go
View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -75,7 +75,7 @@ func (f *File) SetAppProps(appProperties *AppProperties) (err error) {
field string
)
app = new(xlsxProperties)
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(dafaultXMLPathDocPropsApp)))).
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathDocPropsApp)))).
Decode(app); err != nil && err != io.EOF {
err = fmt.Errorf("xml decode error: %s", err)
return
@ -95,14 +95,14 @@ func (f *File) SetAppProps(appProperties *AppProperties) (err error) {
}
app.Vt = NameSpaceDocumentPropertiesVariantTypes.Value
output, err = xml.Marshal(app)
f.saveFileList(dafaultXMLPathDocPropsApp, output)
f.saveFileList(defaultXMLPathDocPropsApp, output)
return
}
// GetAppProps provides a function to get document application properties.
func (f *File) GetAppProps() (ret *AppProperties, err error) {
var app = new(xlsxProperties)
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(dafaultXMLPathDocPropsApp)))).
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathDocPropsApp)))).
Decode(app); err != nil && err != io.EOF {
err = fmt.Errorf("xml decode error: %s", err)
return
@ -181,7 +181,7 @@ func (f *File) SetDocProps(docProperties *DocProperties) (err error) {
)
core = new(decodeCoreProperties)
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(dafaultXMLPathDocPropsCore)))).
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathDocPropsCore)))).
Decode(core); err != nil && err != io.EOF {
err = fmt.Errorf("xml decode error: %s", err)
return
@ -189,7 +189,7 @@ func (f *File) SetDocProps(docProperties *DocProperties) (err error) {
newProps, err = &xlsxCoreProperties{
Dc: NameSpaceDublinCore,
Dcterms: NameSpaceDublinCoreTerms,
Dcmitype: NameSpaceDublinCoreMetadataIntiative,
Dcmitype: NameSpaceDublinCoreMetadataInitiative,
XSI: NameSpaceXMLSchemaInstance,
Title: core.Title,
Subject: core.Subject,
@ -223,7 +223,7 @@ func (f *File) SetDocProps(docProperties *DocProperties) (err error) {
newProps.Modified.Text = docProperties.Modified
}
output, err = xml.Marshal(newProps)
f.saveFileList(dafaultXMLPathDocPropsCore, output)
f.saveFileList(defaultXMLPathDocPropsCore, output)
return
}
@ -232,7 +232,7 @@ func (f *File) SetDocProps(docProperties *DocProperties) (err error) {
func (f *File) GetDocProps() (ret *DocProperties, err error) {
var core = new(decodeCoreProperties)
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(dafaultXMLPathDocPropsCore)))).
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathDocPropsCore)))).
Decode(core); err != nil && err != io.EOF {
err = fmt.Errorf("xml decode error: %s", err)
return

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -35,13 +35,13 @@ func TestSetAppProps(t *testing.T) {
AppVersion: "16.0000",
}))
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetAppProps.xlsx")))
f.Pkg.Store(dafaultXMLPathDocPropsApp, nil)
f.Pkg.Store(defaultXMLPathDocPropsApp, nil)
assert.NoError(t, f.SetAppProps(&AppProperties{}))
assert.NoError(t, f.Close())
// Test unsupported charset
f = NewFile()
f.Pkg.Store(dafaultXMLPathDocPropsApp, MacintoshCyrillicCharset)
f.Pkg.Store(defaultXMLPathDocPropsApp, MacintoshCyrillicCharset)
assert.EqualError(t, f.SetAppProps(&AppProperties{}), "xml decode error: XML syntax error on line 1: invalid UTF-8")
}
@ -53,14 +53,14 @@ func TestGetAppProps(t *testing.T) {
props, err := f.GetAppProps()
assert.NoError(t, err)
assert.Equal(t, props.Application, "Microsoft Macintosh Excel")
f.Pkg.Store(dafaultXMLPathDocPropsApp, nil)
f.Pkg.Store(defaultXMLPathDocPropsApp, nil)
_, err = f.GetAppProps()
assert.NoError(t, err)
assert.NoError(t, f.Close())
// Test unsupported charset
f = NewFile()
f.Pkg.Store(dafaultXMLPathDocPropsApp, MacintoshCyrillicCharset)
f.Pkg.Store(defaultXMLPathDocPropsApp, MacintoshCyrillicCharset)
_, err = f.GetAppProps()
assert.EqualError(t, err, "xml decode error: XML syntax error on line 1: invalid UTF-8")
}
@ -87,13 +87,13 @@ func TestSetDocProps(t *testing.T) {
Version: "1.0.0",
}))
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetDocProps.xlsx")))
f.Pkg.Store(dafaultXMLPathDocPropsCore, nil)
f.Pkg.Store(defaultXMLPathDocPropsCore, nil)
assert.NoError(t, f.SetDocProps(&DocProperties{}))
assert.NoError(t, f.Close())
// Test unsupported charset
f = NewFile()
f.Pkg.Store(dafaultXMLPathDocPropsCore, MacintoshCyrillicCharset)
f.Pkg.Store(defaultXMLPathDocPropsCore, MacintoshCyrillicCharset)
assert.EqualError(t, f.SetDocProps(&DocProperties{}), "xml decode error: XML syntax error on line 1: invalid UTF-8")
}
@ -105,14 +105,14 @@ func TestGetDocProps(t *testing.T) {
props, err := f.GetDocProps()
assert.NoError(t, err)
assert.Equal(t, props.Creator, "Microsoft Office User")
f.Pkg.Store(dafaultXMLPathDocPropsCore, nil)
f.Pkg.Store(defaultXMLPathDocPropsCore, nil)
_, err = f.GetDocProps()
assert.NoError(t, err)
assert.NoError(t, f.Close())
// Test unsupported charset
f = NewFile()
f.Pkg.Store(dafaultXMLPathDocPropsCore, MacintoshCyrillicCharset)
f.Pkg.Store(defaultXMLPathDocPropsCore, MacintoshCyrillicCharset)
_, err = f.GetDocProps()
assert.EqualError(t, err, "xml decode error: XML syntax error on line 1: invalid UTF-8")
}

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

View File

@ -83,7 +83,7 @@ func TestOpenFile(t *testing.T) {
assert.NoError(t, err)
_, err = f.GetCellFormula("Sheet2", "I11")
assert.NoError(t, err)
getSharedForumula(&xlsxWorksheet{}, 0, "")
getSharedFormula(&xlsxWorksheet{}, 0, "")
// Test read cell value with given illegal rows number.
_, err = f.GetCellValue("Sheet2", "a-1")
@ -224,7 +224,7 @@ func TestOpenReader(t *testing.T) {
assert.Equal(t, "SECRET", val)
assert.NoError(t, f.Close())
// Test open spreadsheet with invalid optioins.
// Test open spreadsheet with invalid options.
_, err = OpenReader(bytes.NewReader(oleIdentifier), Options{UnzipSizeLimit: 1, UnzipXMLSizeLimit: 2})
assert.EqualError(t, err, ErrOptionsUnzipSizeLimit.Error())
@ -1065,7 +1065,7 @@ func TestConditionalFormat(t *testing.T) {
// Set conditional format with illegal criteria type.
assert.NoError(t, f.SetConditionalFormat(sheet1, "K1:K10", `[{"type":"data_bar", "criteria":"", "min_type":"min","max_type":"max","bar_color":"#638EC6"}]`))
// Set conditional format with file without dxfs element shold not return error.
// Set conditional format with file without dxfs element should not return error.
f, err = OpenFile(filepath.Join("test", "Book1.xlsx"))
if !assert.NoError(t, err) {
t.FailNow()

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -29,8 +29,8 @@ import (
func NewFile() *File {
f := newFile()
f.Pkg.Store("_rels/.rels", []byte(xml.Header+templateRels))
f.Pkg.Store(dafaultXMLPathDocPropsApp, []byte(xml.Header+templateDocpropsApp))
f.Pkg.Store(dafaultXMLPathDocPropsCore, []byte(xml.Header+templateDocpropsCore))
f.Pkg.Store(defaultXMLPathDocPropsApp, []byte(xml.Header+templateDocpropsApp))
f.Pkg.Store(defaultXMLPathDocPropsCore, []byte(xml.Header+templateDocpropsCore))
f.Pkg.Store("xl/_rels/workbook.xml.rels", []byte(xml.Header+templateWorkbookRels))
f.Pkg.Store("xl/theme/theme1.xml", []byte(xml.Header+templateTheme))
f.Pkg.Store("xl/worksheets/sheet1.xml", []byte(xml.Header+templateSheet))

10
go.mod
View File

@ -5,10 +5,10 @@ go 1.15
require (
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/richardlehane/mscfb v1.0.3
github.com/stretchr/testify v1.6.1
github.com/stretchr/testify v1.7.0
github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985
golang.org/x/text v0.3.6
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d
golang.org/x/text v0.3.7
)

23
go.sum
View File

@ -9,25 +9,24 @@ github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7
github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 h1:EpI0bqf/eX9SdZDwlMmahKM+CDBgNbsXMhsN28XrM8o=
github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8=
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d h1:62NvYBuaanGXR2ZOfwDFkhhl6X1DUgf8qg3GuQvxZsE=
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

6
lib.go
View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -31,7 +31,7 @@ func (f *File) ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) {
err error
docPart = map[string]string{
"[content_types].xml": defaultXMLPathContentTypes,
"xl/sharedstrings.xml": dafaultXMLPathSharedStrings,
"xl/sharedstrings.xml": defaultXMLPathSharedStrings,
}
fileList = make(map[string][]byte, len(r.File))
worksheets int
@ -47,7 +47,7 @@ func (f *File) ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) {
if partName, ok := docPart[strings.ToLower(fileName)]; ok {
fileName = partName
}
if strings.EqualFold(fileName, dafaultXMLPathSharedStrings) && fileSize > f.options.UnzipXMLSizeLimit {
if strings.EqualFold(fileName, defaultXMLPathSharedStrings) && fileSize > f.options.UnzipXMLSizeLimit {
if tempFile, err := f.unzipToTemp(v); err == nil {
f.tempFiles.Store(fileName, tempFile)
continue

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -46,22 +46,22 @@ func (mc *xlsxMergeCell) Rect() ([]int, error) {
// |A8(x3,y4) C8(x4,y4)|
// +------------------------+
//
func (f *File) MergeCell(sheet, hcell, vcell string) error {
rect, err := areaRefToCoordinates(hcell + ":" + vcell)
func (f *File) MergeCell(sheet, hCell, vCell string) error {
rect, err := areaRefToCoordinates(hCell + ":" + vCell)
if err != nil {
return err
}
// Correct the coordinate area, such correct C1:B3 to B1:C3.
_ = sortCoordinates(rect)
hcell, _ = CoordinatesToCellName(rect[0], rect[1])
vcell, _ = CoordinatesToCellName(rect[2], rect[3])
hCell, _ = CoordinatesToCellName(rect[0], rect[1])
vCell, _ = CoordinatesToCellName(rect[2], rect[3])
ws, err := f.workSheetReader(sheet)
if err != nil {
return err
}
ref := hcell + ":" + vcell
ref := hCell + ":" + vCell
if ws.MergeCells != nil {
ws.MergeCells.Cells = append(ws.MergeCells.Cells, &xlsxMergeCell{Ref: ref, rect: rect})
} else {
@ -77,12 +77,12 @@ func (f *File) MergeCell(sheet, hcell, vcell string) error {
// err := f.UnmergeCell("Sheet1", "D3", "E9")
//
// Attention: overlapped areas will also be unmerged.
func (f *File) UnmergeCell(sheet string, hcell, vcell string) error {
func (f *File) UnmergeCell(sheet string, hCell, vCell string) error {
ws, err := f.workSheetReader(sheet)
if err != nil {
return err
}
rect1, err := areaRefToCoordinates(hcell + ":" + vcell)
rect1, err := areaRefToCoordinates(hCell + ":" + vCell)
if err != nil {
return err
}
@ -254,9 +254,9 @@ func mergeCell(cell1, cell2 *xlsxMergeCell) *xlsxMergeCell {
if rect1[3] < rect2[3] {
rect1[3], rect2[3] = rect2[3], rect1[3]
}
hcell, _ := CoordinatesToCellName(rect1[0], rect1[1])
vcell, _ := CoordinatesToCellName(rect1[2], rect1[3])
return &xlsxMergeCell{rect: rect1, Ref: hcell + ":" + vcell}
hCell, _ := CoordinatesToCellName(rect1[0], rect1[1])
vCell, _ := CoordinatesToCellName(rect1[2], rect1[3])
return &xlsxMergeCell{rect: rect1, Ref: hCell + ":" + vCell}
}
// MergeCell define a merged cell data.

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -265,8 +265,8 @@ func (f *File) addPivotCache(pivotCacheID int, pivotCacheXML string, opt *PivotT
}
// data range has been checked
order, _ := f.getPivotFieldsOrder(opt)
hcell, _ := CoordinatesToCellName(coordinates[0], coordinates[1])
vcell, _ := CoordinatesToCellName(coordinates[2], coordinates[3])
hCell, _ := CoordinatesToCellName(coordinates[0], coordinates[1])
vCell, _ := CoordinatesToCellName(coordinates[2], coordinates[3])
pc := xlsxPivotCacheDefinition{
SaveData: false,
RefreshOnLoad: true,
@ -276,7 +276,7 @@ func (f *File) addPivotCache(pivotCacheID int, pivotCacheXML string, opt *PivotT
CacheSource: &xlsxCacheSource{
Type: "worksheet",
WorksheetSource: &xlsxWorksheetSource{
Ref: hcell + ":" + vcell,
Ref: hCell + ":" + vCell,
Sheet: dataSheet,
},
},
@ -320,8 +320,8 @@ func (f *File) addPivotTable(cacheID, pivotTableID int, pivotTableXML string, op
return fmt.Errorf("parameter 'PivotTableRange' parsing error: %s", err.Error())
}
hcell, _ := CoordinatesToCellName(coordinates[0], coordinates[1])
vcell, _ := CoordinatesToCellName(coordinates[2], coordinates[3])
hCell, _ := CoordinatesToCellName(coordinates[0], coordinates[1])
vCell, _ := CoordinatesToCellName(coordinates[2], coordinates[3])
pivotTableStyle := func() string {
if opt.PivotTableStyleName == "" {
@ -345,7 +345,7 @@ func (f *File) addPivotTable(cacheID, pivotTableID int, pivotTableXML string, op
ShowError: &opt.ShowError,
DataCaption: "Values",
Location: &xlsxLocation{
Ref: hcell + ":" + vcell,
Ref: hCell + ":" + vCell,
FirstDataCol: 1,
FirstDataRow: 1,
FirstHeaderRow: 1,
@ -509,7 +509,7 @@ func (f *File) addPivotColFields(pt *xlsxPivotTableDefinition, opt *PivotTableOp
})
}
//in order to create pivot in case there is many Columns and Many Datas
// in order to create pivot in case there is many Columns and Data
if len(opt.Data) > 1 {
pt.ColFields.Field = append(pt.ColFields.Field, &xlsxField{
X: -2,

16
rows.go
View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -290,7 +290,7 @@ func (f *File) getFromStringItemMap(index int) string {
return strconv.Itoa(index)
}
f.sharedStringItemMap = &sync.Map{}
needClose, decoder, tempFile, err := f.xmlDecoder(dafaultXMLPathSharedStrings)
needClose, decoder, tempFile, err := f.xmlDecoder(defaultXMLPathSharedStrings)
if needClose && err == nil {
defer tempFile.Close()
}
@ -369,7 +369,7 @@ func (f *File) getRowHeight(sheet string, row int) int {
return int(convertRowHeightToPixels(v.Ht))
}
}
// Optimisation for when the row heights haven't changed.
// Optimization for when the row heights haven't changed.
return int(defaultRowHeightPixels)
}
@ -398,7 +398,7 @@ func (f *File) GetRowHeight(sheet string, row int) (float64, error) {
return v.Ht, nil
}
}
// Optimisation for when the row heights haven't changed.
// Optimization for when the row heights haven't changed.
return ht, nil
}
@ -411,7 +411,7 @@ func (f *File) sharedStringsReader() *xlsxSST {
relPath := f.getWorkbookRelsPath()
if f.SharedStrings == nil {
var sharedStrings xlsxSST
ss := f.readXML(dafaultXMLPathSharedStrings)
ss := f.readXML(defaultXMLPathSharedStrings)
if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(ss))).
Decode(&sharedStrings); err != nil && err != io.EOF {
log.Printf("xml decode error: %s", err)
@ -443,7 +443,7 @@ func (f *File) sharedStringsReader() *xlsxSST {
}
// getValueFrom return a value from a column/row cell, this function is
// inteded to be used with for range on rows an argument with the spreadsheet
// intended to be used with for range on rows an argument with the spreadsheet
// opened file.
func (c *xlsxC) getValueFrom(f *File, d *xlsxSST, raw bool) (string, error) {
f.Lock()
@ -453,7 +453,7 @@ func (c *xlsxC) getValueFrom(f *File, d *xlsxSST, raw bool) (string, error) {
if c.V != "" {
xlsxSI := 0
xlsxSI, _ = strconv.Atoi(c.V)
if _, ok := f.tempFiles.Load(dafaultXMLPathSharedStrings); ok {
if _, ok := f.tempFiles.Load(defaultXMLPathSharedStrings); ok {
return f.formattedValue(c.S, f.getFromStringItemMap(xlsxSI), raw), nil
}
if len(d.SI) > xlsxSI {
@ -684,7 +684,7 @@ func (f *File) DuplicateRowTo(sheet string, row, row2 int) error {
}
rowCopy.C = append(make([]xlsxC, 0, len(rowCopy.C)), rowCopy.C...)
f.ajustSingleRowDimensions(&rowCopy, row2)
f.adjustSingleRowDimensions(&rowCopy, row2)
if idx2 != -1 {
ws.SheetData.Row[idx2] = rowCopy

View File

@ -207,7 +207,7 @@ func TestColumns(t *testing.T) {
func TestSharedStringsReader(t *testing.T) {
f := NewFile()
f.Pkg.Store(dafaultXMLPathSharedStrings, MacintoshCyrillicCharset)
f.Pkg.Store(defaultXMLPathSharedStrings, MacintoshCyrillicCharset)
f.sharedStringsReader()
si := xlsxSI{}
assert.EqualValues(t, "", si.String())
@ -221,16 +221,16 @@ func TestRowVisibility(t *testing.T) {
f.NewSheet("Sheet3")
assert.NoError(t, f.SetRowVisible("Sheet3", 2, false))
assert.NoError(t, f.SetRowVisible("Sheet3", 2, true))
visiable, err := f.GetRowVisible("Sheet3", 2)
assert.Equal(t, true, visiable)
visible, err := f.GetRowVisible("Sheet3", 2)
assert.Equal(t, true, visible)
assert.NoError(t, err)
visiable, err = f.GetRowVisible("Sheet3", 25)
assert.Equal(t, false, visiable)
visible, err = f.GetRowVisible("Sheet3", 25)
assert.Equal(t, false, visible)
assert.NoError(t, err)
assert.EqualError(t, f.SetRowVisible("Sheet3", 0, true), newInvalidRowNumberError(0).Error())
assert.EqualError(t, f.SetRowVisible("SheetN", 2, false), "sheet SheetN is not exist")
visible, err := f.GetRowVisible("Sheet3", 0)
visible, err = f.GetRowVisible("Sheet3", 0)
assert.Equal(t, false, visible)
assert.EqualError(t, err, newInvalidRowNumberError(0).Error())
_, err = f.GetRowVisible("SheetN", 1)
@ -330,8 +330,9 @@ func TestInsertRow(t *testing.T) {
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestInsertRow.xlsx")))
}
// Testing internal sructure state after insert operations.
// It is important for insert workflow to be constant to avoid side effect with functions related to internal structure.
// Testing internal structure state after insert operations. It is important
// for insert workflow to be constant to avoid side effect with functions
// related to internal structure.
func TestInsertRowInEmptyFile(t *testing.T) {
f := NewFile()
sheet1 := f.GetSheetName(0)

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -304,7 +304,7 @@ func (f *File) relsWriter() {
// setAppXML update docProps/app.xml file of XML.
func (f *File) setAppXML() {
f.saveFileList(dafaultXMLPathDocPropsApp, []byte(templateDocpropsApp))
f.saveFileList(defaultXMLPathDocPropsApp, []byte(templateDocpropsApp))
}
// replaceRelationshipsBytes; Some tools that read spreadsheet files have very

View File

@ -400,7 +400,7 @@ func TestSetActiveSheet(t *testing.T) {
func TestSetSheetName(t *testing.T) {
f := NewFile()
// Test set workksheet with the same name.
// Test set worksheet with the same name.
f.SetSheetName("Sheet1", "Sheet1")
assert.Equal(t, "Sheet1", f.GetSheetName(0))
}

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -153,10 +153,10 @@ func TestSheetPrOptions(t *testing.T) {
}
}
func TestSetSheetrOptions(t *testing.T) {
func TestSetSheetPrOptions(t *testing.T) {
f := NewFile()
assert.NoError(t, f.SetSheetPrOptions("Sheet1", TabColor("")))
// Test SetSheetrOptions on not exists worksheet.
// Test SetSheetPrOptions on not exists worksheet.
assert.EqualError(t, f.SetSheetPrOptions("SheetN"), "sheet SheetN is not exist")
}

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -140,13 +140,13 @@ func (f *File) NewStreamWriter(sheet string) (*StreamWriter, error) {
// called after the rows are written but before Flush.
//
// See File.AddTable for details on the table format.
func (sw *StreamWriter) AddTable(hcell, vcell, format string) error {
func (sw *StreamWriter) AddTable(hCell, vCell, format string) error {
formatSet, err := parseFormatTableSet(format)
if err != nil {
return err
}
coordinates, err := areaRangeToCoordinates(hcell, vcell)
coordinates, err := areaRangeToCoordinates(hCell, vCell)
if err != nil {
return err
}
@ -223,8 +223,8 @@ func (sw *StreamWriter) AddTable(hcell, vcell, format string) error {
}
// Extract values from a row in the StreamWriter.
func (sw *StreamWriter) getRowValues(hrow, hcol, vcol int) (res []string, err error) {
res = make([]string, vcol-hcol+1)
func (sw *StreamWriter) getRowValues(hRow, hCol, vCol int) (res []string, err error) {
res = make([]string, vCol-hCol+1)
r, err := sw.rawData.Reader()
if err != nil {
@ -240,7 +240,7 @@ func (sw *StreamWriter) getRowValues(hrow, hcol, vcol int) (res []string, err er
if err != nil {
return nil, err
}
startElement, ok := getRowElement(token, hrow)
startElement, ok := getRowElement(token, hRow)
if !ok {
continue
}
@ -254,17 +254,17 @@ func (sw *StreamWriter) getRowValues(hrow, hcol, vcol int) (res []string, err er
if err != nil {
return nil, err
}
if col < hcol || col > vcol {
if col < hCol || col > vCol {
continue
}
res[col-hcol] = c.V
res[col-hCol] = c.V
}
return res, nil
}
}
// Check if the token is an XLSX row with the matching row number.
func getRowElement(token xml.Token, hrow int) (startElement xml.StartElement, ok bool) {
func getRowElement(token xml.Token, hRow int) (startElement xml.StartElement, ok bool) {
startElement, ok = token.(xml.StartElement)
if !ok {
return
@ -279,7 +279,7 @@ func getRowElement(token xml.Token, hrow int) (startElement xml.StartElement, ok
continue
}
row, _ := strconv.Atoi(attr.Value)
if row == hrow {
if row == hRow {
ok = true
return
}
@ -406,13 +406,13 @@ func (sw *StreamWriter) SetColWidth(min, max int, width float64) error {
// MergeCell provides a function to merge cells by a given coordinate area for
// the StreamWriter. Don't create a merged cell that overlaps with another
// existing merged cell.
func (sw *StreamWriter) MergeCell(hcell, vcell string) error {
_, err := areaRangeToCoordinates(hcell, vcell)
func (sw *StreamWriter) MergeCell(hCell, vCell string) error {
_, err := areaRangeToCoordinates(hCell, vCell)
if err != nil {
return err
}
sw.mergeCellsCount++
sw.mergeCells += fmt.Sprintf(`<mergeCell ref="%s:%s"/>`, hcell, vcell)
sw.mergeCells += fmt.Sprintf(`<mergeCell ref="%s:%s"/>`, hCell, vCell)
return nil
}
@ -563,7 +563,7 @@ func (bw *bufferedWriter) Write(p []byte) (n int, err error) {
return bw.buf.Write(p)
}
// WriteString wites to the in-memory buffer. The err is always nil.
// WriteString wite to the in-memory buffer. The err is always nil.
func (bw *bufferedWriter) WriteString(p string) (n int, err error) {
return bw.buf.WriteString(p)
}

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -1101,7 +1101,7 @@ func (f *File) styleSheetWriter() {
func (f *File) sharedStringsWriter() {
if f.SharedStrings != nil {
output, _ := xml.Marshal(f.SharedStrings)
f.saveFileList(dafaultXMLPathSharedStrings, f.replaceNameSpaceBytes(dafaultXMLPathSharedStrings, output))
f.saveFileList(defaultXMLPathSharedStrings, f.replaceNameSpaceBytes(defaultXMLPathSharedStrings, output))
}
}
@ -2168,7 +2168,7 @@ func (f *File) SetDefaultFont(fontName string) {
s.CellStyles.CellStyle[0].CustomBuiltIn = &custom
}
// readDefaultFont provides an unmarshalled font value.
// readDefaultFont provides an un-marshalled font value.
func (f *File) readDefaultFont() *xlsxFont {
s := f.stylesReader()
return s.Fonts.Font[0]
@ -2724,42 +2724,42 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
// }
// err = f.SetCellStyle("Sheet1", "H9", "H9", style)
//
func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) error {
hcol, hrow, err := CellNameToCoordinates(hcell)
func (f *File) SetCellStyle(sheet, hCell, vCell string, styleID int) error {
hCol, hRow, err := CellNameToCoordinates(hCell)
if err != nil {
return err
}
vcol, vrow, err := CellNameToCoordinates(vcell)
vCol, vRow, err := CellNameToCoordinates(vCell)
if err != nil {
return err
}
// Normalize the coordinate area, such correct C1:B3 to B1:C3.
if vcol < hcol {
vcol, hcol = hcol, vcol
if vCol < hCol {
vCol, hCol = hCol, vCol
}
if vrow < hrow {
vrow, hrow = hrow, vrow
if vRow < hRow {
vRow, hRow = hRow, vRow
}
hcolIdx := hcol - 1
hrowIdx := hrow - 1
hColIdx := hCol - 1
hRowIdx := hRow - 1
vcolIdx := vcol - 1
vrowIdx := vrow - 1
vColIdx := vCol - 1
vRowIdx := vRow - 1
ws, err := f.workSheetReader(sheet)
if err != nil {
return err
}
prepareSheetXML(ws, vcol, vrow)
makeContiguousColumns(ws, hrow, vrow, vcol)
prepareSheetXML(ws, vCol, vRow)
makeContiguousColumns(ws, hRow, vRow, vCol)
ws.Lock()
defer ws.Unlock()
for r := hrowIdx; r <= vrowIdx; r++ {
for k := hcolIdx; k <= vcolIdx; k++ {
for r := hRowIdx; r <= vRowIdx; r++ {
for k := hColIdx; k <= vColIdx; k++ {
ws.SheetData.Row[r].C[k].S = styleID
}
}

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -61,27 +61,27 @@ func parseFormatTableSet(formatSet string) (*formatTable, error) {
// TableStyleMedium1 - TableStyleMedium28
// TableStyleDark1 - TableStyleDark11
//
func (f *File) AddTable(sheet, hcell, vcell, format string) error {
func (f *File) AddTable(sheet, hCell, vCell, format string) error {
formatSet, err := parseFormatTableSet(format)
if err != nil {
return err
}
// Coordinate conversion, convert C1:B3 to 2,0,1,2.
hcol, hrow, err := CellNameToCoordinates(hcell)
hCol, hRow, err := CellNameToCoordinates(hCell)
if err != nil {
return err
}
vcol, vrow, err := CellNameToCoordinates(vcell)
vCol, vRow, err := CellNameToCoordinates(vCell)
if err != nil {
return err
}
if vcol < hcol {
vcol, hcol = hcol, vcol
if vCol < hCol {
vCol, hCol = hCol, vCol
}
if vrow < hrow {
vrow, hrow = hrow, vrow
if vRow < hRow {
vRow, hRow = hRow, vRow
}
tableID := f.countTables() + 1
@ -94,7 +94,7 @@ func (f *File) AddTable(sheet, hcell, vcell, format string) error {
return err
}
f.addSheetNameSpace(sheet, SourceRelationship)
if err = f.addTable(sheet, tableXML, hcol, hrow, vcol, vrow, tableID, formatSet); err != nil {
if err = f.addTable(sheet, tableXML, hCol, hRow, vCol, vRow, tableID, formatSet); err != nil {
return err
}
f.addContentTypePart(tableID, "table")
@ -257,9 +257,9 @@ func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) {
// Excel also allows some simple string matching operations:
//
// x == b* // begins with b
// x != b* // doesnt begin with b
// x != b* // doesn't begin with b
// x == *b // ends with b
// x != *b // doesnt end with b
// x != *b // doesn't end with b
// x == *b* // contains b
// x != *b* // doesn't contains b
//
@ -276,27 +276,27 @@ func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) {
// col < 2000
// Price < 2000
//
func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
hcol, hrow, err := CellNameToCoordinates(hcell)
func (f *File) AutoFilter(sheet, hCell, vCell, format string) error {
hCol, hRow, err := CellNameToCoordinates(hCell)
if err != nil {
return err
}
vcol, vrow, err := CellNameToCoordinates(vcell)
vCol, vRow, err := CellNameToCoordinates(vCell)
if err != nil {
return err
}
if vcol < hcol {
vcol, hcol = hcol, vcol
if vCol < hCol {
vCol, hCol = hCol, vCol
}
if vrow < hrow {
vrow, hrow = hrow, vrow
if vRow < hRow {
vRow, hRow = hRow, vRow
}
formatSet, _ := parseAutoFilterSet(format)
cellStart, _ := CoordinatesToCellName(hcol, hrow, true)
cellEnd, _ := CoordinatesToCellName(vcol, vrow, true)
cellStart, _ := CoordinatesToCellName(hCol, hRow, true)
cellEnd, _ := CoordinatesToCellName(vCol, vRow, true)
ref, filterDB := cellStart+":"+cellEnd, "_xlnm._FilterDatabase"
wb := f.workbookReader()
sheetID := f.GetSheetIndex(sheet)
@ -324,8 +324,8 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
wb.DefinedNames.DefinedName = append(wb.DefinedNames.DefinedName, d)
}
}
refRange := vcol - hcol
return f.autoFilter(sheet, ref, refRange, hcol, formatSet)
refRange := vCol - hCol
return f.autoFilter(sheet, ref, refRange, hCol, formatSet)
}
// autoFilter provides a function to extract the tokens from the filter

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -24,10 +24,10 @@ var (
const (
defaultXMLPathContentTypes = "[Content_Types].xml"
dafaultXMLPathDocPropsApp = "docProps/app.xml"
dafaultXMLPathDocPropsCore = "docProps/core.xml"
dafaultXMLPathCalcChain = "xl/calcChain.xml"
dafaultXMLPathSharedStrings = "xl/sharedStrings.xml"
defaultXMLPathDocPropsApp = "docProps/app.xml"
defaultXMLPathDocPropsCore = "docProps/core.xml"
defaultXMLPathCalcChain = "xl/calcChain.xml"
defaultXMLPathSharedStrings = "xl/sharedStrings.xml"
defaultXMLPathStyles = "xl/styles.xml"
defaultXMLPathWorkbook = "xl/workbook.xml"
)

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -111,10 +111,8 @@ type decodePicLocks struct {
NoSelect bool `xml:"noSelect,attr,omitempty"`
}
// decodeBlip directly maps the blip element in the namespace
// http://purl.oclc.org/ooxml/officeDoc ument/relationships - This element
// specifies the existence of an image (binary large image or picture) and
// contains a reference to the image data.
// decodeBlip element specifies the existence of an image (binary large image
// or picture) and contains a reference to the image data.
type decodeBlip struct {
Embed string `xml:"embed,attr"`
Cstate string `xml:"cstate,attr,omitempty"`

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
@ -62,7 +62,7 @@ const (
StrictNameSpaceSpreadSheet = "http://purl.oclc.org/ooxml/spreadsheetml/main"
NameSpaceDublinCore = "http://purl.org/dc/elements/1.1/"
NameSpaceDublinCoreTerms = "http://purl.org/dc/terms/"
NameSpaceDublinCoreMetadataIntiative = "http://purl.org/dc/dcmitype/"
NameSpaceDublinCoreMetadataInitiative = "http://purl.org/dc/dcmitype/"
ContentTypeDrawing = "application/vnd.openxmlformats-officedocument.drawing+xml"
ContentTypeDrawingML = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
ContentTypeMacro = "application/vnd.ms-excel.sheet.macroEnabled.main+xml"
@ -160,10 +160,8 @@ type xlsxPicLocks struct {
NoSelect bool `xml:"noSelect,attr,omitempty"`
}
// xlsxBlip directly maps the blip element in the namespace
// http://purl.oclc.org/ooxml/officeDoc ument/relationships - This element
// specifies the existence of an image (binary large image or picture) and
// contains a reference to the image data.
// xlsxBlip element specifies the existence of an image (binary large image or
// picture) and contains a reference to the image data.
type xlsxBlip struct {
Embed string `xml:"r:embed,attr"`
Cstate string `xml:"cstate,attr,omitempty"`

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//

View File

@ -1,4 +1,4 @@
// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//