MCPcopy
hub / github.com/qax-os/excelize / setSharedString

Method setSharedString

cell.go:487–509  ·  view source on GitHub ↗

setSharedString provides a function to add string to the share string table.

(val string)

Source from the content-addressed store, hash-verified

485
486// setSharedString provides a function to add string to the share string table.
487func (f *File) setSharedString(val string) (int, error) {
488 if err := f.sharedStringsLoader(); err != nil {
489 return 0, err
490 }
491 sst, err := f.sharedStringsReader()
492 if err != nil {
493 return 0, err
494 }
495 f.mu.Lock()
496 defer f.mu.Unlock()
497 if i, ok := f.sharedStringsMap[val]; ok {
498 return i, nil
499 }
500 sst.mu.Lock()
501 defer sst.mu.Unlock()
502 t := xlsxT{Val: val}
503 val, t.Space = trimCellValue(val, false)
504 sst.SI = append(sst.SI, xlsxSI{T: &t})
505 sst.Count = len(sst.SI)
506 sst.UniqueCount = sst.Count
507 f.sharedStringsMap[val] = sst.UniqueCount - 1
508 return sst.UniqueCount - 1, nil
509}
510
511// trimCellValue provides a function to set string type to cell.
512func trimCellValue(value string, escape bool) (v string, ns xml.Attr) {

Callers 1

setCellStringMethod · 0.95

Calls 3

sharedStringsLoaderMethod · 0.95
sharedStringsReaderMethod · 0.95
trimCellValueFunction · 0.85

Tested by

no test coverage detected