Browse Source

HUE-3697 [hive] Excel download convert decimal types to strings

Jenny Kim 9 years ago
parent
commit
9da3651
1 changed files with 4 additions and 2 deletions
  1. 4 2
      desktop/core/src/desktop/lib/export_csvxls.py

+ 4 - 2
desktop/core/src/desktop/lib/export_csvxls.py

@@ -20,6 +20,7 @@ Common library to export either CSV or XLS.
 """
 import gc
 import logging
+import numbers
 import openpyxl
 import re
 import six
@@ -45,8 +46,9 @@ def encode_row(row, encoding=None, is_xls=False):
   for cell in row:
     if is_xls and isinstance(cell, six.string_types):
       cell = re.sub(XLS_ILLEGAL_CHARS, '?', cell)
-    if isinstance(cell, six.string_types):
-      cell = smart_str(nullify(cell), encoding or i18n.get_site_encoding(), strings_only=True, errors='replace')
+    cell = nullify(cell)
+    if not isinstance(cell, numbers.Number):
+      cell = smart_str(cell, encoding or i18n.get_site_encoding(), strings_only=True, errors='replace')
     encoded_row.append(cell)
   return encoded_row