While I was working with a few excel files, I found one formatting issue with the numbers that are in the "text" format.
For example, if I have a zip code cell 85043, which is in "text" format in excel. The output value would be 90000 after the conversion. The numbers seem to be "rounded up or down" in this case.
I think it may result from the following function in xlsx2html.format. In the above scenario, the cell_format is '@' instead of 'General'.
So I'm curious if there's any preferred way of handling this type of data? Modifying the if statement could be temporary fix, but I' afraid it might fail in some other situations. Any suggestions? Many thanks!
def format_cell(cell, locale=None, f_cell=None):
value = cell.value
formatted_value = value or ' '
cell_format = cell.number_format
if not cell_format:
return format_hyperlink(formatted_value, cell.hyperlink)
if isinstance(value, six.integer_types) or isinstance(value, float):
if cell_format.lower() != 'general':
locale = locale or LC_NUMERIC
formatted_value = format_decimal(value, cell_format, locale=locale)
...
Hi, thank you for this great work!
While I was working with a few excel files, I found one formatting issue with the numbers that are in the "text" format.
For example, if I have a zip code cell
85043
, which is in "text" format in excel. The output value would be90000
after the conversion. The numbers seem to be "rounded up or down" in this case.I think it may result from the following function in
xlsx2html.format
. In the above scenario, thecell_format
is'@'
instead of'General'
.So I'm curious if there's any preferred way of handling this type of data? Modifying the
if
statement could be temporary fix, but I' afraid it might fail in some other situations. Any suggestions? Many thanks!