fix xlsx import export

pull/5/head
“christopheseux” 2023-05-23 10:19:46 +02:00
parent 56562e7052
commit ed44047395
1 changed files with 6 additions and 3 deletions

View File

@ -133,7 +133,7 @@ class VSETB_OT_spreadsheet_from_file(Operator):
from openpyxl import Workbook
workbook = openpyxl.load_workbook(filepath, read_only=True)
workbook = openpyxl.load_workbook(filepath, read_only=True, data_only=True)
sheet = workbook.active
rows = [(c.value or '') for r in sheet.rows for c in r]
@ -142,7 +142,7 @@ class VSETB_OT_spreadsheet_from_file(Operator):
self.report({'ERROR'}, f'File extension {filepath.suffix} should be in [.csv, .xlsx]')
return {'CANCELLED'}
rows = [r for r in rows if any(r)]
rows = [[(c.value or '') for c in r] for r in sheet.rows]
cell_types = project.get_cell_types()
for cell_name in rows[0]:
@ -526,7 +526,10 @@ class VSETB_OT_export_spreadsheet(Operator):
rows = []
# Header
rows.append([cell.export_name for cell in cells])
if spreadsheet.use_custom_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')
delimiter = spreadsheet.delimiter.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')