Created
March 12, 2025 08:45
-
-
Save zeffii/e43f585e5933133af80bfbe06561386b to your computer and use it in GitHub Desktop.
xlsm_writer.py - issue sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import xlsxwriter | |
fname = r"C:\Users\DealgaMcArdle\Documents\Blender Experiments\creating_EXCEL_FILE\excel_example\xls_output.xlsx" | |
# prepare data | |
sdata = bpy.data.texts['data'].as_string().split('\n') | |
names_and_dateissued = [s.split(' ') for s in sdata] | |
structured_data = {} | |
for name, date in names_and_dateissued: | |
filename, revision = name.split('_v') | |
revision = revision.replace('.pdf', '') | |
if not filename in structured_data: | |
structured_data[filename] = [] | |
structured_data[filename].append([revision, date]) | |
print(structured_data) | |
workbook = xlsxwriter.Workbook(fname) | |
worksheet = workbook.add_worksheet() | |
revision_cell_id = {'C01': 'D', 'C02': 'E', 'C03': 'F', 'C04': 'G'} | |
for idx, i in enumerate(structured_data, 1): | |
print(idx, i) | |
cell_file_id = f'A{idx}' | |
cell_file_descriptor = f'B{idx}' | |
worksheet.write(cell_file_id, i) | |
worksheet.write(cell_file_descriptor, 'description') | |
for (rev, rdate) in structured_data[i]: | |
lookup = revision_cell_id[rev] | |
revison_cell = f'{lookup}{idx}' | |
worksheet.write(revison_cell, rev) | |
workbook.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment