From ab12307393461e7055f664d296a3a0e686eebb39 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 21 Aug 2022 01:09:32 +0800 Subject: [PATCH] This made library allowing insert EMZ and WMZ format image - Update dependencies module --- excelize.go | 6 +++--- go.mod | 4 ++-- go.sum | 8 ++++---- picture.go | 2 +- picture_test.go | 4 ++++ test/images/excel.emz | Bin 0 -> 2233 bytes test/images/excel.wmz | Bin 0 -> 1919 bytes xmlDrawing.go | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 test/images/excel.emz create mode 100644 test/images/excel.wmz diff --git a/excelize.go b/excelize.go index f3b4381d..f1269fef 100644 --- a/excelize.go +++ b/excelize.go @@ -394,12 +394,12 @@ func (f *File) addRels(relPath, relType, target, targetMode string) int { } // UpdateLinkedValue fix linked values within a spreadsheet are not updating in -// Office Excel 2007 and 2010. This function will be remove value tag when met a +// Office Excel application. This function will be remove value tag when met a // cell have a linked value. Reference // https://social.technet.microsoft.com/Forums/office/en-US/e16bae1f-6a2c-4325-8013-e989a3479066/excel-2010-linked-cells-not-updating // -// Notice: after open XLSX file Excel will be update linked value and generate -// new value and will prompt save file or not. +// Notice: after opening generated workbook, Excel will update the linked value +// and generate a new value and will prompt to save the file or not. // // For example: // diff --git a/go.mod b/go.mod index 0fda8100..b03e2546 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ require ( github.com/stretchr/testify v1.7.1 github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa + golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 - golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced + golang.org/x/net v0.0.0-20220812174116-3211cb980234 golang.org/x/text v0.3.7 gopkg.in/yaml.v3 v3.0.0 // indirect ) diff --git a/go.sum b/go.sum index a79ea1f2..9512add0 100644 --- a/go.sum +++ b/go.sum @@ -17,13 +17,13 @@ github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj0 github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M= github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c= +golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE= golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/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-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9WKk6PdGOrb9n+SbIvw= -golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E= +golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= 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= diff --git a/picture.go b/picture.go index 84c77316..d087c61e 100644 --- a/picture.go +++ b/picture.go @@ -363,7 +363,7 @@ func (f *File) addMedia(file []byte, ext string) string { // setContentTypePartImageExtensions provides a function to set the content // type for relationship parts and the Main Document part. func (f *File) setContentTypePartImageExtensions() { - imageTypes := map[string]string{"jpeg": "image/", "png": "image/", "gif": "image/", "tiff": "image/", "emf": "image/x-", "wmf": "image/x-"} + imageTypes := map[string]string{"jpeg": "image/", "png": "image/", "gif": "image/", "tiff": "image/", "emf": "image/x-", "wmf": "image/x-", "emz": "image/x-", "wmz": "image/x-"} content := f.contentTypesReader() content.Lock() defer content.Unlock() diff --git a/picture_test.go b/picture_test.go index 3ac1afb6..37ccdc56 100644 --- a/picture_test.go +++ b/picture_test.go @@ -98,8 +98,12 @@ func TestAddPictureErrors(t *testing.T) { decodeConfig := func(r io.Reader) (image.Config, error) { return image.Config{Height: 100, Width: 90}, nil } image.RegisterFormat("emf", "", decode, decodeConfig) image.RegisterFormat("wmf", "", decode, decodeConfig) + image.RegisterFormat("emz", "", decode, decodeConfig) + image.RegisterFormat("wmz", "", decode, decodeConfig) assert.NoError(t, f.AddPicture("Sheet1", "Q1", filepath.Join("test", "images", "excel.emf"), "")) assert.NoError(t, f.AddPicture("Sheet1", "Q7", filepath.Join("test", "images", "excel.wmf"), "")) + assert.NoError(t, f.AddPicture("Sheet1", "Q13", filepath.Join("test", "images", "excel.emz"), "")) + assert.NoError(t, f.AddPicture("Sheet1", "Q19", filepath.Join("test", "images", "excel.wmz"), "")) assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture2.xlsx"))) assert.NoError(t, f.Close()) } diff --git a/test/images/excel.emz b/test/images/excel.emz new file mode 100644 index 0000000000000000000000000000000000000000..bc9480153a46787e76fbbd2521b8e1e73e3fc1d9 GIT binary patch literal 2233 zcmV;q2uAlGiwFpBF#loz|7mSuXJsyBZDs(ynq6!Z*A>U_cxOt??5=m$_yZ6QhOBVN z#+Wz`#@`lQi7U?R0*Yx6g7&fv{fJSoIdm=^s!G7 zLXlcU$wMh3sG@3;My-eGIrpA>=gxR`c4v3Z==?Q1Gk33l=brzaS?i9$7~2cFY%;d6 z;JO8ivF|yq`{_l-F1_QrZ@&v1z?2W6PIB?HIJbd3GZf$YF>D}AR4v;ovf{o>X+yM^!b+TVK;bU(EZ zZdS-S{rmWxVaj1OaoF&s^)Noja~yOP@?H(cy>NaH?AzenHFJ&Qsi>*sTsI$bZh(3$ zPa8o6s{|^7wkp}ydZiKK7^9ruK4)<4KXuDRg^f#s^6CD~0bgEtzDFCQupH3~nBy7B z@xKcq$9o}1?E8kfupo6Ebj`d4Vvu7-$+q%JUDiEH1vvJUQL?Rt1*ux{l|IOvnOx)p znJ?!4IB10ON<%&=$ZG@avEA25f?wot&CIKuqQ<%F_1ReCY{1`5l9w(J&vH0k2Iq6I z@8TRu$5TdATFEIRSCe6-ohGZrNkC3kS*786651wf@|zt0_HS;E9RJ`rSdedCn^OkO zF&u|Uno|j=gQuY~8q+kcWP&Vf6f^?LE7dcn(#M8k)f#imP>y>k$28@L-fQ7GW*kph zP>$r~Zu#WZuAX|e77MZJl>p{(Ef@6dC>&#s+bEYN81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U^|2~!l;gD$xI|! zMCdrNOw^EvhhTZ7L*YacEv<<-%R{epK!J_ODB(x#RGIZ zO~hH|-+lP&=R0d9s#LP-Of+^p+xH0k_Wt~jLU_ZkTJGo6t_`3r+uoex<%J zH!I!L^qG0LrXJD;pRU6>p}U>G!*`^DYm0H#s^xo{{eOPZH?B=Adab%gduI{VY2f4@+?+b2};iD|mEuo2q!fa=Mqn)ed1y?igRncjcvwY;@r`Cg)}-kZetL$|8; zE58BP4pKj#yWSctZa*i0Wvpr4Bzu<4vHk3D86Q{L^m=sC=TfQUd&jq(KI8RofxZJm zfA57{?tq*Q;F>bEHR#$?v_@T`zY}ba{mii4Y#)vPa@y;j(8p4r&uP$#Kpy`GOub?+ H_$&YbR>)@k literal 0 HcmV?d00001 diff --git a/test/images/excel.wmz b/test/images/excel.wmz new file mode 100644 index 0000000000000000000000000000000000000000..d6089680745e83186790e7a4ebd04720387a85d2 GIT binary patch literal 1919 zcmV-_2Y~n=iwFqcF#loz|7mSuXJsyTZDs)N-CIl)R~QHILG6QCz=d^zMvJy-qiLHO zMWNmWMHIK&loBA7#)=58Qk1I{5J7GQLI}3>p%|m7ma1v=!JtXohZfT+0j#y58roo+ zK445F@kNc`_B(TShnX{%on3bK4Cy)flbyZco*(D?&dk2}$KcOja{S2R9Nb6z(WcB0 zZZ5~o&X4D~5H2|$JvIk^W`%_Cw{L~S@V9e9!nhaU)-(&f0v(0Ua=`CF??^N)<_0)) z4-NP2QvTmT_t9^T;UC*pz;V~Y@sE2r*guYitA)E)u3Sk^Pk;9885}=& z@W5`jswn}@v+Tjd-(8SSy`D)Hl99x8vH3te@sqJW@KcfrKJg=Ze`vw)MGosE64LvL?yPEO9FM~^6eet(U-ckdPz6%`g14h#%9d6vw~%;x6io}M13 z$l?0+>!qcoO-)UMgM&`D0~~a8bkx??K7an4>LmOyE?l^9=FFK(mo9a8cf(y+1_cEL zBO@af6%|gA1I+j0#fyD?eO+B$PLTtw6EHk~{yf!5_+ix4)WAv@9UX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