Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExport-Excel: Numeric values not correct #168
Comments
In issue #64 we did some tests which fixed some issues we had. However, when I do the same test for the value '1.555,83' it doesn't recognize it as a number. For value '0,26' it is correctly recognized but converted to '26' as you can see below:
Result:
|
I think I found it,
This generates the correct values being:
This is correct, even the '1.2' being converted on my system to '12'. This is because the dot separater is used for thousands. Please let me know what you think? |
- Changed 'InvariantInfo' to 'CurrentInfo', to respect the systems regioinal settings - Added verbose text to see what's happening
I'll review. Nicely played, correctly handles US zip code "07670" and maintains the leading zero. Oops, I lied, looked at the wrong column in the output. The leading zero is stripped. |
Hi Doug, that is correct, the leading zero would be stripped because it means nothing and is handled as a number in Excel. This is actually default behavior of Excel, you can see this when you open a new Excel worksheet and type in a cell for example So, in short. to have a US ZIP code like
The same is true for a phone number. When there are spaces between the numbers ( At this moment, your code already provides us with a way of formatting all fields as text by using -
Result: So I guess the best solution is to tell the module to treat these values as Excel
When there is an I would love to hear what you think about this. |
Thanks! I need to do more investigation. This looks to be on the right track. I'll get back to you and we can discuss further. |
Same issue here, I need to make a report based on db data, and one column contains numbers with leading zeros which needs to be stored as text. |
Took me more than a week to reorganize the code, add some better verbose and stuff. Anyhow, it's now possible to have numbers the way you want them by using '-NoNumberConversion *' as added in PR #187 . Waiting for approval/review from the boss to make sure I didn't miss anything ;) |
So, I'm having problems with numbers showing up like this: 1,49545E+14 instead of this: 149544511912832. Will this latest fix resolve this? |
If the pull request gets accepted then you can use the parameter '-NoNumberConversion' to send your data to Excel. By using this parameter you bypass the conversion from a value to a number, that is built in to the function. So in theory, if you do: Then Export-Excel will export all data 'as is' and it doesn't convert anything. So this should avoid Excel from truncating the number from '149544511912832' to '1,49545E+14', because it's passed as a string and not as a number and is shown as plain text. |
@pezmannen These changes are going to take a while to test. Let me know if you want try out an early version? Plus, if you run into issues, you can report back. |
@dfinke I'd love to test, and I'll report any issues. Thanks! |
I have the same problem with numbers - 0,04 is converted to 4.00. Is there any plan to merge this? I would like to install a new version instead of using the forked version DarkLite1.... |
It's been merged and published to the PowerShell gallery |
Consider the following code:
This results in:

As you can see, the values behind the comma are discarded.
Example: 0,26 becomes 26 in the Excel file.
Also, some cells are stored as text rather then number. see C3.