fix: Excel export prohibits inputting external links or formulas (#3106)

This commit is contained in:
shaohuzhang1 2025-05-19 14:04:16 +08:00 committed by GitHub
parent 5e0d8048f9
commit a1a92a833a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -661,10 +661,9 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
cell = worksheet.cell(row=row_idx + 1, column=col_idx + 1)
if isinstance(col, str):
col = re.sub(ILLEGAL_CHARACTERS_RE, '', col)
if col.startswith(('=', '+', '-', '@')):
cell.value = '\ufeff' + col
else:
cell.value = col
if col.startswith(('=', '+', '-', '@')):
col = '\ufeff' + col
cell.value = col
# 创建HttpResponse对象返回Excel文件
return workbook