Jan-17-2019, 04:59 PM
buran,
Per your suggestions and the debug link, I moved all the way back to just making changes to the full data set and just saving it as a different file. Here's what I have so far, and it's working. I'll continue to try to move forward piece by piece. Thank you for all your help and patience.
Joe
Per your suggestions and the debug link, I moved all the way back to just making changes to the full data set and just saving it as a different file. Here's what I have so far, and it's working. I'll continue to try to move forward piece by piece. Thank you for all your help and patience.
Joe
import os, glob, shutil, openpyxl from pathlib import Path from collections import defaultdict from openpyxl.reader.excel import load_workbook from openpyxl import Workbook from openpyxl.compat import range from openpyxl.utils import get_column_letter from openpyxl.styles import Font from datetime import datetime startTime = datetime.now() os.chdir("c://test") mainfile = 'Example.xlsx' wb = load_workbook(mainfile) ws = wb.active dims = {} for row in ws.rows: for cell in row: cell.font = Font(name = 'Courier New', sz = 12) if cell.value: dims[cell.column] = max((dims.get(cell.column, 0), len(str(cell.value)))) for col, value in dims.items(): #print(col, value) ws.column_dimensions[col].width = int(value * 1.3) wb.save(filename = "output.xlsx") print(datetime.now() - startTime)