浏览代码

[fix] Not able to export general ledger report's data if data has illegal characters

version-14
Rohit Waghchaure 7 年前
父节点
当前提交
f8928dc999
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. +6
    -1
      frappe/utils/xlsxutils.py

+ 6
- 1
frappe/utils/xlsxutils.py 查看文件

@@ -6,11 +6,12 @@ import frappe
from frappe.utils import encode, cstr, cint, flt, comma_or

import openpyxl
import re
from openpyxl.styles import Font
from openpyxl import load_workbook
from six import StringIO, string_types

ILLEGAL_CHARACTERS_RE = re.compile(r'[\000-\010]|[\013-\014]|[\016-\037]')
# return xlsx file object
def make_xlsx(data, sheet_name, wb=None):

@@ -30,6 +31,10 @@ def make_xlsx(data, sheet_name, wb=None):
else:
value = item

if isinstance(item, string_types) and next(ILLEGAL_CHARACTERS_RE.finditer(value), None):
# Remove illegal characters from the string
value = re.sub(ILLEGAL_CHARACTERS_RE, '', value)

clean_row.append(value)

ws.append(clean_row)


正在加载...
取消
保存