From ed440473955a37bcab529b8bea9e76dcf8078be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchristopheseux=E2=80=9D?= <“seuxchristophe@hotmail.fr”> Date: Tue, 23 May 2023 10:19:46 +0200 Subject: [PATCH] fix xlsx import export --- operators/spreadsheet.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/operators/spreadsheet.py b/operators/spreadsheet.py index 243db79..a9fcfd7 100644 --- a/operators/spreadsheet.py +++ b/operators/spreadsheet.py @@ -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')