perf: 优化 csv import export

This commit is contained in:
ibuler
2023-03-13 17:57:50 +08:00
parent 6a9e013f2f
commit 6bb42b8d59
4 changed files with 15 additions and 4 deletions

View File

@@ -1,13 +1,16 @@
import pyexcel
from .base import BaseFileParser
class ExcelFileParser(BaseFileParser):
media_type = 'text/xlsx'
def generate_rows(self, stream_data):
workbook = pyexcel.get_book(file_type='xlsx', file_content=stream_data)
try:
workbook = pyexcel.get_book(file_type='xlsx', file_content=stream_data)
except Exception:
raise Exception('Invalid excel file')
# 默认获取第一个工作表sheet
sheet = workbook.sheet_by_index(0)
rows = sheet.rows()