win32com 엑셀 행높이 열너비 자동맞춤

            # 자동 행높이/열너비 맞춤
            import win32com.client as win32
            excel = win32.Dispatch('Excel.Application')
            load_wb = excel.Workbooks.Open(savefilename)
            # excel.Visible = True
            for sh in load_wb.Sheets:
                ws = load_wb.Worksheets(sh.Name)
                ws.Columns.AutoFit() # 열너비
                # ws.Rows.AutoFit() # 행높이

            load_wb.Save()
            excel.Application.Quit()

Leave a Comment