|
|
@ -1,4 +1,5 @@
|
|
|
|
import pyexcel
|
|
|
|
import pyexcel
|
|
|
|
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
|
|
|
|
|
|
|
from .base import BaseFileParser
|
|
|
|
from .base import BaseFileParser
|
|
|
|
|
|
|
|
|
|
|
@ -10,7 +11,7 @@ class ExcelFileParser(BaseFileParser):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
workbook = pyexcel.get_book(file_type='xlsx', file_content=stream_data)
|
|
|
|
workbook = pyexcel.get_book(file_type='xlsx', file_content=stream_data)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
raise Exception('Invalid excel file')
|
|
|
|
raise Exception(_('Invalid excel file'))
|
|
|
|
# 默认获取第一个工作表sheet
|
|
|
|
# 默认获取第一个工作表sheet
|
|
|
|
sheet = workbook.sheet_by_index(0)
|
|
|
|
sheet = workbook.sheet_by_index(0)
|
|
|
|
rows = sheet.rows()
|
|
|
|
rows = sheet.rows()
|
|
|
|