Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
修订版 | ab12307393461e7055f664d296a3a0e686eebb39 (tree) |
---|---|
时间 | 2022-08-21 02:09:32 |
作者 | ![]() |
Commiter | xuri |
This made library allowing insert EMZ and WMZ format image
- Update dependencies module
@@ -394,12 +394,12 @@ func (f *File) addRels(relPath, relType, target, targetMode string) int { | ||
394 | 394 | } |
395 | 395 | |
396 | 396 | // 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 | |
398 | 398 | // cell have a linked value. Reference |
399 | 399 | // https://social.technet.microsoft.com/Forums/office/en-US/e16bae1f-6a2c-4325-8013-e989a3479066/excel-2010-linked-cells-not-updating |
400 | 400 | // |
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. | |
403 | 403 | // |
404 | 404 | // For example: |
405 | 405 | // |
@@ -10,9 +10,9 @@ require ( | ||
10 | 10 | github.com/stretchr/testify v1.7.1 |
11 | 11 | github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 |
12 | 12 | 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 | |
14 | 14 | 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 | |
16 | 16 | golang.org/x/text v0.3.7 |
17 | 17 | gopkg.in/yaml.v3 v3.0.0 // indirect |
18 | 18 | ) |
@@ -17,13 +17,13 @@ github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj0 | ||
17 | 17 | github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= |
18 | 18 | github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M= |
19 | 19 | 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= | |
22 | 22 | golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE= |
23 | 23 | golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= |
24 | 24 | 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= | |
27 | 27 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
28 | 28 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
29 | 29 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
@@ -363,7 +363,7 @@ func (f *File) addMedia(file []byte, ext string) string { | ||
363 | 363 | // setContentTypePartImageExtensions provides a function to set the content |
364 | 364 | // type for relationship parts and the Main Document part. |
365 | 365 | 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-"} | |
367 | 367 | content := f.contentTypesReader() |
368 | 368 | content.Lock() |
369 | 369 | defer content.Unlock() |
@@ -98,8 +98,12 @@ func TestAddPictureErrors(t *testing.T) { | ||
98 | 98 | decodeConfig := func(r io.Reader) (image.Config, error) { return image.Config{Height: 100, Width: 90}, nil } |
99 | 99 | image.RegisterFormat("emf", "", decode, decodeConfig) |
100 | 100 | image.RegisterFormat("wmf", "", decode, decodeConfig) |
101 | + image.RegisterFormat("emz", "", decode, decodeConfig) | |
102 | + image.RegisterFormat("wmz", "", decode, decodeConfig) | |
101 | 103 | assert.NoError(t, f.AddPicture("Sheet1", "Q1", filepath.Join("test", "images", "excel.emf"), "")) |
102 | 104 | 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"), "")) | |
103 | 107 | assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture2.xlsx"))) |
104 | 108 | assert.NoError(t, f.Close()) |
105 | 109 | } |
@@ -142,7 +142,7 @@ const ( | ||
142 | 142 | ) |
143 | 143 | |
144 | 144 | // 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"} | |
146 | 146 | |
147 | 147 | // xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This |
148 | 148 | // element specifies non-visual canvas properties. This allows for additional |