@@ -20,7 +20,6 @@ import (
2020 "io"
2121 "strconv"
2222 "strings"
23- "unsafe"
2423)
2524
2625// ReadZipReader can be used to read the spreadsheet in memory without touching the
@@ -251,17 +250,11 @@ func namespaceStrictToTransitional(content []byte) []byte {
251250 StrictNameSpaceSpreadSheet : NameSpaceSpreadSheet .Value ,
252251 }
253252 for s , n := range namespaceTranslationDic {
254- content = bytesReplace (content , stringToBytes (s ), stringToBytes (n ), - 1 )
253+ content = bytesReplace (content , [] byte (s ), [] byte (n ), - 1 )
255254 }
256255 return content
257256}
258257
259- // stringToBytes cast a string to bytes pointer and assign the value of this
260- // pointer.
261- func stringToBytes (s string ) []byte {
262- return * (* []byte )(unsafe .Pointer (& s ))
263- }
264-
265258// bytesReplace replace old bytes with given new.
266259func bytesReplace (s , old , new []byte , n int ) []byte {
267260 if n == 0 {
@@ -366,7 +359,7 @@ func getXMLNamespace(space string, attr []xml.Attr) string {
366359// replaceNameSpaceBytes provides a function to replace the XML root element
367360// attribute by the given component part path and XML content.
368361func (f * File ) replaceNameSpaceBytes (path string , contentMarshal []byte ) []byte {
369- var oldXmlns = stringToBytes (`xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">` )
362+ var oldXmlns = [] byte (`xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">` )
370363 var newXmlns = []byte (templateNamespaceIDMap )
371364 if attr , ok := f .xmlAttr [path ]; ok {
372365 newXmlns = []byte (genXMLNamespace (attr ))
0 commit comments