diff options
author | Ri Xu <xuri.me@gmail.com> | 2017-03-28 11:48:09 +0800 |
---|---|---|
committer | Ri Xu <xuri.me@gmail.com> | 2017-03-28 11:48:09 +0800 |
commit | bee487c445768b8afd15bbfa7caa4d8427e4c880 (patch) | |
tree | 4b31fc11a593ad1a02e7f0726aa1d6fe6895fa97 /excelize.go | |
parent | b6254209fe56c84a9ac99805ce3dd877a494e134 (diff) |
Leading space(s) character in cell value detection added. Related issue #32.
Diffstat (limited to 'excelize.go')
-rw-r--r-- | excelize.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/excelize.go b/excelize.go index 1fbfcc2..e723cb5 100644 --- a/excelize.go +++ b/excelize.go @@ -161,6 +161,15 @@ func (f *File) SetCellStr(sheet, axis, value string) { completeRow(xlsx, rows, cell) completeCol(xlsx, rows, cell) + // Leading space(s) character detection. + if len(value) > 0 { + if value[0] == 32 { + xlsx.SheetData.Row[xAxis].C[yAxis].XMLSpace = xml.Attr{ + Name: xml.Name{Space: NameSpaceXML, Local: "space"}, + Value: "preserve", + } + } + } xlsx.SheetData.Row[xAxis].C[yAxis].T = "str" xlsx.SheetData.Row[xAxis].C[yAxis].V = value } |