-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamWriter to support writing ints, floats, etc. to the cells #1048
Comments
Thanks for your issue, as you says, the value paramter in the |
I am working with a use case where the number and type of columns is not static but decided at runtime. Thus, I pack the values in an interface{} slice and call Once I have my project completed, I will work out a simple example to check whether there actually is an issue or not and let you know. In the meanwhile, I have just used |
Below is some code which demonstrates the problem that I encountered. However, while I originally thought that the data from the interface slice was not written correctly to the cells according to the underlying datatype, I now see that it is formatting using The code below creates a new excel file Go version: 1.17.1 windows/amd64 Code:
|
Sorry for my late reply. This issue is similar to issues #725, #777, and #826. |
The SetRow function of the StreamWriter struct has the row values to be written as interface{}, i.e.:
func (sw *StreamWriter) SetRow(axis string, values []interface{}, opts ...RowOpts) error
Thus one can write any datatypes to the row as long as they are converted to interface{}. I would have expected that when writing an int, float or time value that the SetRow function would write to the cell similarly to writing a cell using the SetCellInt and SetCellFloat functions since the underlying type of the interface would be available. Instead, the values are all written as text in the general format. Thus, numbers will appear as "Number formatted as text" rather than actual numbers for which a number format can be set using the SetColStyle function.
Is there a way to write numbers properly using the StreamWriter or alternatively a fast way to get the texts converted to numbers, or does one instead of the StreamWriter function have to use the SetCell.. functions to get the values stored as proper numbers?
The idea of the StreamWriter is to load data fast to a sheet. However, the need for having proper numbers stored in the sheets is not less for larger datasets -- probably rather the other way around.
The text was updated successfully, but these errors were encountered: