소스 검색

[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 from frappe.utils import encode, cstr, cint, flt, comma_or


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


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


@@ -30,6 +31,10 @@ def make_xlsx(data, sheet_name, wb=None):
else: else:
value = item 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) clean_row.append(value)


ws.append(clean_row) ws.append(clean_row)


불러오는 중...
취소
저장