Closed nicolasfranck closed 4 months ago
Thanks for your issue. This was duplicated with issue #705, you can set cell A1
as text by number format like this:
var style int
if style, err = f.NewStyle(&excelize.Style{NumFmt: 49}); err != nil {
fmt.Println(err)
return
}
if err = f.SetCellStyle("Sheet1", "A1", "A1", style); err != nil {
fmt.Println(err)
return
}
This library also support set multiple cell's style by SetColStyle
and SetRowStyle
functions.
I am not sure what this means: should the method SetCellStr
do this actually, or should cell styling do this?
What does NumFmt 49 do btw?
The SetCellStr
function used for accept Go language's string data type value, this function won't affect the format of the cell, so if you need set cell style with specified number format, may need to create the style with number format by the NewStyle
function at first, and you will get a style index, and then set cells style with that. The excelize library supports create style with number format by built-in number format index or custom number format code, the number 49
represents the "Text" format. As the comments in issue #705 say, you can find more built-in number format mapping details on the documentation website.
Ok, thanks!
Description
When I use the method SetCellStr I get cells that are formatted by Microsoft Excel with format "General" instead of the expected format "Text"
Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.):
MAC OS X