Browse Source

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

Jenny Kim 9 years ago
parent
commit
cc7db0545b
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

@@ -22,6 +22,7 @@ import gc
 import logging
 import logging
 import openpyxl
 import openpyxl
 import re
 import re
+import six
 import StringIO
 import StringIO
 import tablib
 import tablib
 
 
@@ -42,9 +43,10 @@ def nullify(cell):
 def encode_row(row, encoding=None, is_xls=False):
 def encode_row(row, encoding=None, is_xls=False):
   encoded_row = []
   encoded_row = []
   for cell in row:
   for cell in row:
-    if is_xls and isinstance(cell, str):
+    if is_xls and isinstance(cell, six.string_types):
       cell = re.sub(XLS_ILLEGAL_CHARS, '?', cell)
       cell = re.sub(XLS_ILLEGAL_CHARS, '?', cell)
-    cell = smart_str(nullify(cell), encoding or i18n.get_site_encoding(), strings_only=True, errors='replace')
+    if isinstance(cell, six.string_types):
+      cell = smart_str(nullify(cell), encoding or i18n.get_site_encoding(), strings_only=True, errors='replace')
     encoded_row.append(cell)
     encoded_row.append(cell)
   return encoded_row
   return encoded_row