Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Numbers stored as string #205

Closed
arisdario opened this issue Apr 27, 2016 · 4 comments
Closed

Numbers stored as string #205

arisdario opened this issue Apr 27, 2016 · 4 comments
Milestone

Comments

@arisdario
Copy link

Is there a way to avoid this?, for me is fine to get some columns with data stored as text, but in some case where i have only values like: "10.00" or "19.99" i don't want to store this kind of values as text, i need to select each cell and convert to value manually and if have 20k rows is really painful ! sometimes work with all selected sometimes some value break this selection !. Thx

@adrilo
Copy link
Collaborator

adrilo commented Apr 27, 2016

Unfortunately, it's not currently possible. Spout inserts all values with the "General" type.
I'll add this to the todo list for v3 though.

@adrilo adrilo added this to the 3.0.0 milestone Apr 27, 2016
@arisdario
Copy link
Author

Thanks !

@jaminion
Copy link

jaminion commented May 3, 2016

I thought it might be worth mentioning that when you set your array elements that you pass to addRow() or addRows(), you can explicitly cast them to have them set as a numeric value in the cell instead of a string, at least with XLSX. In \Box\Spout\Writer\XLSX\Internal\Worksheet, the addRow() function uses CellHelper::isNumeric() to determine if the value is numeric, which in turn checks the return value from gettype() for that value.

Assuming you are pushing data into your spreadsheet from an array or object:

$data = array($obj->myStringValue(), (double)$obj->myDecimalValue(), (int)$obj->myIntValue());
$writer->addRow($data);

This is currently working for me.

@adrilo, your work on this project is much appreciated.

@arisdario
Copy link
Author

@adrilo, thanks for your hint. I will test this version and also i will test the performance and speed of writing a sheet whit 40k values. and i will post the rrsults. Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants