fix import xlsx
parent
ed44047395
commit
9b1c8e0d09
|
@ -133,16 +133,16 @@ class VSETB_OT_spreadsheet_from_file(Operator):
|
||||||
|
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
workbook = openpyxl.load_workbook(filepath, read_only=True, data_only=True)
|
workbook = openpyxl.load_workbook(filepath, read_only=True)
|
||||||
sheet = workbook.active
|
sheet = workbook.active
|
||||||
|
|
||||||
rows = [(c.value or '') for r in sheet.rows for c in r]
|
rows = [[(c.value or '') for c in r] for r in sheet.rows]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.report({'ERROR'}, f'File extension {filepath.suffix} should be in [.csv, .xlsx]')
|
self.report({'ERROR'}, f'File extension {filepath.suffix} should be in [.csv, .xlsx]')
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
rows = [[(c.value or '') for c in r] for r in sheet.rows]
|
rows = [r for r in rows if any(r)]
|
||||||
|
|
||||||
cell_types = project.get_cell_types()
|
cell_types = project.get_cell_types()
|
||||||
for cell_name in rows[0]:
|
for cell_name in rows[0]:
|
||||||
|
@ -526,10 +526,7 @@ class VSETB_OT_export_spreadsheet(Operator):
|
||||||
rows = []
|
rows = []
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
if spreadsheet.use_custom_cells:
|
|
||||||
rows.append([cell.export_name for cell in cells])
|
rows.append([cell.export_name for cell in cells])
|
||||||
else:
|
|
||||||
rows.append([cell.name for cell in cells])
|
|
||||||
|
|
||||||
separator = spreadsheet.separator.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
separator = spreadsheet.separator.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
||||||
delimiter = spreadsheet.delimiter.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
delimiter = spreadsheet.delimiter.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
||||||
|
|
Loading…
Reference in New Issue