mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 22:02:06 -06:00
[GH-ISSUE #293] Writing a number in percent format #236
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#236
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sapomuyverde on GitHub (Jun 1, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/293
Originally assigned to: @jmcnamara on GitHub.
Hi,
I receive data from sql and one of the columns comes in a percentage format something like 81.46% the data type is string.
If i write something like:
format_set_num_format (format1, "0.00%")
worksheet_write_number (worksheet, 10, 0, salesPercentage, format1)
I get this 8146.00%, Instead of what I expect, which is this 81.46%
On the other hand, if I treat the data as a string
worksheet_write_string (worksheet, 10, 0, salesPercentage, )
I display the correct data as I want in Excel, but with the warning number stored as text, which I want to avoid.
Any ideas how I could format percentage correctly.
Regards,
Javier
@jmcnamara commented on GitHub (Jun 1, 2020):
In Excel percentages are divided by 100. You can verify that by creating a percentage in Excel and then converting it to a number.
So the same thing applies with Libxlsxwriter. You will need to divide the numbers by 100 and apply the number format.
@sapomuyverde commented on GitHub (Jun 2, 2020):
Hi,
It works perfect, I appreciate your help.
Regards
Javier