@@ -21,7 +21,6 @@ import (
21
21
"strconv"
22
22
"strings"
23
23
"time"
24
- "unicode/utf16"
25
24
26
25
"github.com/xuri/efp"
27
26
)
@@ -447,7 +446,7 @@ func (f *File) SetCellStr(sheet, cell, value string) error {
447
446
448
447
// setCellString provides a function to set string type to shared string table.
449
448
func (f * File ) setCellString (value string ) (t , v string , err error ) {
450
- if len ( utf16 . Encode ([] rune ( value )) ) > TotalCellChars {
449
+ if countUTF16String ( value ) > TotalCellChars {
451
450
value = truncateUTF16Units (value , TotalCellChars )
452
451
}
453
452
t = "s"
@@ -510,7 +509,7 @@ func (f *File) setSharedString(val string) (int, error) {
510
509
511
510
// trimCellValue provides a function to set string type to cell.
512
511
func trimCellValue (value string , escape bool ) (v string , ns xml.Attr ) {
513
- if len ( utf16 . Encode ([] rune ( value )) ) > TotalCellChars {
512
+ if countUTF16String ( value ) > TotalCellChars {
514
513
value = truncateUTF16Units (value , TotalCellChars )
515
514
}
516
515
if value != "" {
@@ -1211,7 +1210,7 @@ func setRichText(runs []RichTextRun) ([]xlsxR, error) {
1211
1210
totalCellChars int
1212
1211
)
1213
1212
for _ , textRun := range runs {
1214
- totalCellChars += len ( utf16 . Encode ([] rune ( textRun .Text )) )
1213
+ totalCellChars += countUTF16String ( textRun .Text )
1215
1214
if totalCellChars > TotalCellChars {
1216
1215
return textRuns , ErrCellCharsLength
1217
1216
}
0 commit comments