Skip to content

Commit cff16fa

Browse files
committed
- Supplemental worksheet struct fields and field order adjustment
- Testing case for set and get doc properties - Update charts struct XML tags
1 parent db99373 commit cff16fa

File tree

8 files changed

+306
-180
lines changed

8 files changed

+306
-180
lines changed

cellmerged.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of
2+
// this source code is governed by a BSD-style license that can be found in
3+
// the LICENSE file.
4+
//
5+
// Package excelize providing a set of functions that allow you to write to
6+
// and read from XLSX files. Support reads and writes XLSX file generated by
7+
// Microsoft Excel™ 2007 and later. Support save file without losing original
8+
// charts of XLSX. This library needs Go version 1.8 or later.
9+
110
package excelize
211

312
import "strings"
413

5-
// GetMergeCells provides a function to get all merged cells from a worksheet currently.
14+
// GetMergeCells provides a function to get all merged cells from a worksheet
15+
// currently.
616
func (f *File) GetMergeCells(sheet string) ([]MergeCell, error) {
717
var mergeCells []MergeCell
818
xlsx, err := f.workSheetReader(sheet)
@@ -45,4 +55,4 @@ func (m *MergeCell) GetStartAxis() string {
4555
func (m *MergeCell) GetEndAxis() string {
4656
axis := strings.Split((*m)[0], ":")
4757
return axis[1]
48-
}
58+
}

docProps.go

100755100644
File mode changed.

docProps_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of
2+
// this source code is governed by a BSD-style license that can be found in
3+
// the LICENSE file.
4+
//
5+
// Package excelize providing a set of functions that allow you to write to
6+
// and read from XLSX files. Support reads and writes XLSX file generated by
7+
// Microsoft Excel™ 2007 and later. Support save file without losing original
8+
// charts of XLSX. This library needs Go version 1.8 or later.
9+
10+
package excelize
11+
12+
import (
13+
"path/filepath"
14+
"testing"
15+
16+
"github.com/stretchr/testify/assert"
17+
)
18+
19+
func TestSetDocProps(t *testing.T) {
20+
f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
21+
if !assert.NoError(t, err) {
22+
t.FailNow()
23+
}
24+
assert.NoError(t, f.SetDocProps(&DocProperties{
25+
Category: "category",
26+
ContentStatus: "Draft",
27+
Created: "2019-06-04T22:00:10Z",
28+
Creator: "Go Excelize",
29+
Description: "This file created by Go Excelize",
30+
Identifier: "xlsx",
31+
Keywords: "Spreadsheet",
32+
LastModifiedBy: "Go Author",
33+
Modified: "2019-06-04T22:00:10Z",
34+
Revision: "0",
35+
Subject: "Test Subject",
36+
Title: "Test Title",
37+
Language: "en-US",
38+
Version: "1.0.0",
39+
}))
40+
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetDocProps.xlsx")))
41+
f.XLSX["docProps/core.xml"] = nil
42+
assert.EqualError(t, f.SetDocProps(&DocProperties{}), "EOF")
43+
}
44+
45+
func TestGetDocProps(t *testing.T) {
46+
f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
47+
if !assert.NoError(t, err) {
48+
t.FailNow()
49+
}
50+
props, err := f.GetDocProps()
51+
assert.NoError(t, err)
52+
assert.Equal(t, props.Creator, "Microsoft Office User")
53+
f.XLSX["docProps/core.xml"] = nil
54+
_, err = f.GetDocProps()
55+
assert.EqualError(t, err, "EOF")
56+
}

excelize_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func TestBrokenFile(t *testing.T) {
192192

193193
t.Run("SaveAsEmptyStruct", func(t *testing.T) {
194194
// Test write file with broken file struct with given path.
195-
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestBrokenFile.SaveAsEmptyStruct.xlsx")))
195+
assert.NoError(t, f.SaveAs(filepath.Join("test", "BrokenFile.SaveAsEmptyStruct.xlsx")))
196196
})
197197

198198
t.Run("OpenBadWorkbook", func(t *testing.T) {

0 commit comments

Comments
 (0)