From ddeed48fc19e814e1ec2c04580108f7b865cf181 Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Tue, 20 Dec 2016 20:46:19 +0800 Subject: [PATCH] - Fix issue background image and table missing after save; - Update test template for this fix --- sheet.go | 2 ++ test/Workbook1.xlsx | Bin 18395 -> 21643 bytes xmlWorksheet.go | 58 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/sheet.go b/sheet.go index 36488d59..088a6512 100644 --- a/sheet.go +++ b/sheet.go @@ -125,6 +125,8 @@ func replaceRelationshipsNameSpace(workbookMarshal string) string { func replaceRelationshipsID(workbookMarshal string) string { rids := strings.Replace(workbookMarshal, ``, ``, -1) rids = strings.Replace(rids, ``, ``, -1) + rids = strings.Replace(rids, ``, ``, -1) + rids = strings.Replace(rids, ``, ``, -1) return strings.Replace(rids, `O9bitFZrlJ@mTcGwdq1@SJUZdHx=R*wnhDqEc2_l_6 z7byN4%Bq`IRvNs4VUzVz;ym?lL9C5~PQ%uZONdfA5vC-XcuO?96V%Z&1e#htCBH!W z(UWHBdh8+geL4tJtXEP2Ssne#oFqo=*NISak!`q#iZ#BSIi7eAzhzH8h5C5jCQWA{ zJK(RI(cQUj`YC*hB}PAZv|6YG+=P(tAbXD6Y{O0xBC06-m4Wh9Uc|*NC#x?rIW|rd zhm&T@LDnnNMd{reFLGWA&T!*4Jy^Z^#9(L4RM7lpby+`wWpF`ktt8$EEHHfztI^Uc>HzSlg)e#@|#`tb_ z&GA>P)2&%VX!s+;JT5K5^ph4F$bE#{b8pd>YLnXq2M*(rM$&nRlOAsG2;b2vd6mb0 zpCl;_Y9V2-7#pfjzLY^v`bB>>+XyRv6SxpP)QTDs7S_Lc1c7e8su%?eficiXh^dN+A@>R}z^1)C`e18b{tR^Cuv{K@ zaFVGmk5PA3XFoF9#k+OAA{wo`1FAf+%C-R2@Ct)$Ac4 zkTd}ZbXh~c$!s0XtSx!D?VK&G;}M?v_wJK^Fd#;#cVR19aE6GWgBymyU^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mH171o1>ZW_N-ux4Fg`GLheLHvS;>(t2FK;>% z13EEccfEzjq!vmxhU}1{itwT)M6Zbtb%=aW3_Z7M`Ht;5`e57fwngW|tZIAn8}=Xl zIBlu{H|wPI8lHaAj$zpj=hx`qTgoGR7v&~2{>6FXUi{cft|QN?@kYMEg#j0L?T!bU z`|PWjIRV*}VGEY-wFl%uv9n=^9ag3b-)=eg$d6-0UK%$PidhLOYPH!N_rY+=`{G$r zuX!BlIGDa2cvprb&HnCFn7@_7M78Np{y3jsl4iCi-AIRff6i?RX7z^J%*7pX&TEx! z@~O+CdVM_8<{^S#2|BcJFwb;v#cG6jfJ3sd=>hU?FIC>1*Lz&`o4B3j-BZ@@-WUyh zh8xEnmNCSCj!q5aR-j)Rc)eWoqok@d4dw(k(kM^H&4f|Je!coAH3-iBVpK$?;k+IOL>5RZ6P>{{84bplyF@@1V} z2(T{r-X$0w1$SK>Q4OLrB^5drf(}HjvD>uyBHu0_K^#N=zt-RwaG0imfAd(NnvaO; zEf@|K+`=jWE{)>!ZJeTO;%vk5jfF%6$0x4!H~dr$-zFbXo8)gbNv_fK3Y5E&@#gOZ zuJDl`iEV;oKJslZGYIe)5ZjRmzW`}F zXkfw>3kp35m^LkN*&`H>)!_%9keCw1OaO5%Cdhadlo3PM2XUVA__c{g3tsO@z$EH} zATwF8--W95zQ9fCAO?a0)+7YDx|DF_zC-)r_2m^U95@yK^ bVUYzAj_ZM^mw~t{@`$Z$fS|{gh)w7}U7~2G diff --git a/xmlWorksheet.go b/xmlWorksheet.go index 349350e1..02794e46 100644 --- a/xmlWorksheet.go +++ b/xmlWorksheet.go @@ -23,6 +23,8 @@ type xlsxWorksheet struct { PageSetUp xlsxPageSetUp `xml:"pageSetup"` HeaderFooter xlsxHeaderFooter `xml:"headerFooter"` Drawing xlsxDrawing `xml:"drawing"` + Picture xlsxPicture `xml:"picture"` + TableParts xlsxTableParts `xml:"tableParts"` } // xlsxDrawing change r:id to rid in the namespace. @@ -292,3 +294,59 @@ type xlsxHyperlink struct { Display string `xml:"display,attr,omitempty"` RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` } + +// xlsxTableParts directly maps the tableParts element in the namespace +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - +// The table element has several attributes applied to identify the table +// and the data range it covers. The table id attribute needs to be unique +// across all table parts, the same goes for the name and displayName. The +// displayName has the further restriction that it must be unique across +// all defined names in the workbook. Later on we will see that you can +// define names for many elements, such as cells or formulas. The name +// value is used for the object model in Microsoft Office Excel. The +// displayName is used for references in formulas. The ref attribute is +// used to identify the cell range that the table covers. This includes +// not only the table data, but also the table header containing column +// names. +// To add columns to your table you add new tableColumn elements to the +// tableColumns container. Similar to the shared string table the +// collection keeps a count attribute identifying the number of columns. +// Besides the table definition in the table part there is also the need +// to identify which tables are displayed in the worksheet. The worksheet +// part has a separate element tableParts to store this information. Each +// table part is referenced through the relationship ID and again a count +// of the number of table parts is maintained. The following markup sample +// is taken from the documents accompanying this book. The sheet data +// element has been removed to reduce the size of the sample. To reference +// the table, just add the tableParts element, of course after having +// created and stored the table part. +// Example: +// +// +// ... +// +// +// +// +// +type xlsxTableParts struct { + Count int `xml:"count,attr"` + TableParts []xlsxTablePart `xml:"tablePart"` +} + +// xlsxTablePart directly maps the tablePart element in the namespace +// http://schemas.openxmlformats.org/spreadsheetml/2006/main +type xlsxTablePart struct { + RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` +} + +// xlsxPicture directly maps the picture element in the namespace +// http://schemas.openxmlformats.org/spreadsheetml/2006/main - +// Background sheet image. +// Example: +// +// +// +type xlsxPicture struct { + RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` // Relationship Id pointing to the image part. +}