diff options
author | xuri <xuri.me@gmail.com> | 2019-03-21 14:09:25 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-03-21 14:09:25 +0800 |
commit | 70b1a29165867643e961ceef27592349a122ab7c (patch) | |
tree | 0f35760bab29f9966966ab78e6cd5681a16af910 /cell.go | |
parent | b2c12d784e94bfb14da800962c769f5a0f6f783e (diff) |
Use bitSize for float32 type numbers conversion, relate PR #361
Diffstat (limited to 'cell.go')
-rw-r--r-- | cell.go | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -143,18 +143,20 @@ func (f *File) SetCellBool(sheet, axis string, value bool) { } // SetCellFloat sets a floating point value into a cell. The prec parameter -// specifies how many places after the decimal will be shown while -1 -// is a special value that will use as many decimal places as necessary to -// represent the number. bitSize is 32 or 64 depending on if a float32 or float64 -// was originally used for the value -// var x float32 = 1.325 -// f.SetCellFloat("Sheet1", "A1", float64(x), 2, 32) +// specifies how many places after the decimal will be shown while -1 is a +// special value that will use as many decimal places as necessary to +// represent the number. bitSize is 32 or 64 depending on if a float32 or +// float64 was originally used for the value. For Example: +// +// var x float32 = 1.325 +// f.SetCellFloat("Sheet1", "A1", float64(x), 2, 32) +// func (f *File) SetCellFloat(sheet, axis string, value float64, prec, bitSize int) { xlsx := f.workSheetReader(sheet) cellData, col, _ := f.prepareCell(xlsx, sheet, axis) cellData.S = f.prepareCellStyle(xlsx, col, cellData.S) cellData.T = "" - cellData.V = strconv.FormatFloat(value, 'f', prec, 64) + cellData.V = strconv.FormatFloat(value, 'f', prec, bitSize) } // SetCellStr provides a function to set string type value of a cell. Total |