Skip to content

Commit ab12307

Browse files
committed
This made library allowing insert EMZ and WMZ format image
- Update dependencies module
1 parent cfa2d60 commit ab12307

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

excelize.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,12 @@ func (f *File) addRels(relPath, relType, target, targetMode string) int {
394394
}
395395

396396
// UpdateLinkedValue fix linked values within a spreadsheet are not updating in
397-
// Office Excel 2007 and 2010. This function will be remove value tag when met a
397+
// Office Excel application. This function will be remove value tag when met a
398398
// cell have a linked value. Reference
399399
// https://social.technet.microsoft.com/Forums/office/en-US/e16bae1f-6a2c-4325-8013-e989a3479066/excel-2010-linked-cells-not-updating
400400
//
401-
// Notice: after open XLSX file Excel will be update linked value and generate
402-
// new value and will prompt save file or not.
401+
// Notice: after opening generated workbook, Excel will update the linked value
402+
// and generate a new value and will prompt to save the file or not.
403403
//
404404
// For example:
405405
//

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ require (
1010
github.com/stretchr/testify v1.7.1
1111
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470
1212
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22
13-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
13+
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8
1414
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
15-
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced
15+
golang.org/x/net v0.0.0-20220812174116-3211cb980234
1616
golang.org/x/text v0.3.7
1717
gopkg.in/yaml.v3 v3.0.0 // indirect
1818
)

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj0
1717
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
1818
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M=
1919
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
20-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
21-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
20+
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
21+
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
2222
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE=
2323
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
2424
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
25-
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9WKk6PdGOrb9n+SbIvw=
26-
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
25+
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
26+
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
2727
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2828
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2929
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

picture.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func (f *File) addMedia(file []byte, ext string) string {
363363
// setContentTypePartImageExtensions provides a function to set the content
364364
// type for relationship parts and the Main Document part.
365365
func (f *File) setContentTypePartImageExtensions() {
366-
imageTypes := map[string]string{"jpeg": "image/", "png": "image/", "gif": "image/", "tiff": "image/", "emf": "image/x-", "wmf": "image/x-"}
366+
imageTypes := map[string]string{"jpeg": "image/", "png": "image/", "gif": "image/", "tiff": "image/", "emf": "image/x-", "wmf": "image/x-", "emz": "image/x-", "wmz": "image/x-"}
367367
content := f.contentTypesReader()
368368
content.Lock()
369369
defer content.Unlock()

picture_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ func TestAddPictureErrors(t *testing.T) {
9898
decodeConfig := func(r io.Reader) (image.Config, error) { return image.Config{Height: 100, Width: 90}, nil }
9999
image.RegisterFormat("emf", "", decode, decodeConfig)
100100
image.RegisterFormat("wmf", "", decode, decodeConfig)
101+
image.RegisterFormat("emz", "", decode, decodeConfig)
102+
image.RegisterFormat("wmz", "", decode, decodeConfig)
101103
assert.NoError(t, f.AddPicture("Sheet1", "Q1", filepath.Join("test", "images", "excel.emf"), ""))
102104
assert.NoError(t, f.AddPicture("Sheet1", "Q7", filepath.Join("test", "images", "excel.wmf"), ""))
105+
assert.NoError(t, f.AddPicture("Sheet1", "Q13", filepath.Join("test", "images", "excel.emz"), ""))
106+
assert.NoError(t, f.AddPicture("Sheet1", "Q19", filepath.Join("test", "images", "excel.wmz"), ""))
103107
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture2.xlsx")))
104108
assert.NoError(t, f.Close())
105109
}

test/images/excel.emz

2.18 KB
Binary file not shown.

test/images/excel.wmz

1.87 KB
Binary file not shown.

xmlDrawing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const (
142142
)
143143

144144
// supportedImageTypes defined supported image types.
145-
var supportedImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff", ".emf": ".emf", ".wmf": ".wmf"}
145+
var supportedImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff", ".emf": ".emf", ".wmf": ".wmf", ".emz": ".emz", ".wmz": ".wmz"}
146146

147147
// xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This
148148
// element specifies non-visual canvas properties. This allows for additional

0 commit comments

Comments
 (0)