@@ -15,7 +15,6 @@ import (
15
15
"encoding/xml"
16
16
"errors"
17
17
"fmt"
18
- "html"
19
18
"reflect"
20
19
"strconv"
21
20
"strings"
@@ -274,23 +273,16 @@ func (f *File) SetCellStr(sheet, axis, value string) error {
274
273
return err
275
274
}
276
275
cellData .S = f .prepareCellStyle (xlsx , col , cellData .S )
277
- cellData .T , cellData .V , cellData . XMLSpace = f .setCellString (value )
276
+ cellData .T , cellData .V = f .setCellString (value )
278
277
return err
279
278
}
280
279
281
280
// setCellString provides a function to set string type to shared string
282
281
// table.
283
- func (f * File ) setCellString (value string ) (t string , v string , ns xml. Attr ) {
282
+ func (f * File ) setCellString (value string ) (t string , v string ) {
284
283
if len (value ) > TotalCellChars {
285
284
value = value [0 :TotalCellChars ]
286
285
}
287
- // Leading and ending space(s) character detection.
288
- if len (value ) > 0 && (value [0 ] == 32 || value [len (value )- 1 ] == 32 ) {
289
- ns = xml.Attr {
290
- Name : xml.Name {Space : NameSpaceXML , Local : "space" },
291
- Value : "preserve" ,
292
- }
293
- }
294
286
t = "s"
295
287
v = strconv .Itoa (f .setSharedString (value ))
296
288
return
@@ -304,7 +296,16 @@ func (f *File) setSharedString(val string) int {
304
296
}
305
297
sst .Count ++
306
298
sst .UniqueCount ++
307
- sst .SI = append (sst .SI , xlsxSI {T : val })
299
+ t := xlsxT {Val : val }
300
+ // Leading and ending space(s) character detection.
301
+ if len (val ) > 0 && (val [0 ] == 32 || val [len (val )- 1 ] == 32 ) {
302
+ ns := xml.Attr {
303
+ Name : xml.Name {Space : NameSpaceXML , Local : "space" },
304
+ Value : "preserve" ,
305
+ }
306
+ t .Space = ns
307
+ }
308
+ sst .SI = append (sst .SI , xlsxSI {T : & t })
308
309
f .sharedStringsMap [val ] = sst .UniqueCount - 1
309
310
return sst .UniqueCount - 1
310
311
}
@@ -620,7 +621,7 @@ func (f *File) SetCellRichText(sheet, cell string, runs []RichTextRun) error {
620
621
sst := f .sharedStringsReader ()
621
622
textRuns := []xlsxR {}
622
623
for _ , textRun := range runs {
623
- run := xlsxR {T : & xlsxT {Val : html . EscapeString ( textRun .Text ) }}
624
+ run := xlsxR {T : & xlsxT {Val : textRun .Text }}
624
625
if strings .ContainsAny (textRun .Text , "\r \n " ) {
625
626
run .T .Space = xml.Attr {Name : xml.Name {Space : NameSpaceXML , Local : "space" }, Value : "preserve" }
626
627
}
0 commit comments