|
23 | 23 | from django.db.models import QuerySet, Count |
24 | 24 | from django.db.models.functions import Substr, Reverse |
25 | 25 | from django.http import HttpResponse |
| 26 | +from django.utils.translation import get_language |
| 27 | +from django.utils.translation import gettext_lazy as _, gettext, to_locale |
26 | 28 | from drf_yasg import openapi |
27 | 29 | from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE |
28 | 30 | from rest_framework import serializers |
|
64 | 66 | embedding_by_document_list |
65 | 67 | from setting.models import Model |
66 | 68 | from smartdoc.conf import PROJECT_DIR |
67 | | -from django.utils.translation import gettext_lazy as _, gettext, to_locale |
68 | | -from django.utils.translation import get_language |
69 | 69 |
|
70 | 70 | parse_qa_handle_list = [XlsParseQAHandle(), CsvParseQAHandle(), XlsxParseQAHandle(), ZipParseQAHandle()] |
71 | 71 | parse_table_handle_list = [CsvSplitTableHandle(), XlsSplitTableHandle(), XlsxSplitTableHandle()] |
@@ -661,7 +661,10 @@ def get_workbook(data_dict, document_dict): |
661 | 661 | cell = worksheet.cell(row=row_idx + 1, column=col_idx + 1) |
662 | 662 | if isinstance(col, str): |
663 | 663 | col = re.sub(ILLEGAL_CHARACTERS_RE, '', col) |
664 | | - cell.value = col |
| 664 | + if col.startswith(('=', '+', '-', '@')): |
| 665 | + cell.value = '\ufeff' + col |
| 666 | + else: |
| 667 | + cell.value = col |
665 | 668 | # 创建HttpResponse对象返回Excel文件 |
666 | 669 | return workbook |
667 | 670 |
|
|
0 commit comments