Copy the following code lines and paste them to the python idle. You will be able to get a new excel file like the following.
from openpyxl import Workbook from openpyxl.styles import Font # Create a new workbook workbook = Workbook() # Select the active sheet sheet = workbook.active # Set column widths sheet.column_dimensions['A'].width = 30 sheet.column_dimensions['B'].width = 15 # Define balance sheet data balance_sheet_data = [ ["Assets", ""], ["Current Assets", ""], ["Cash", "$100,000"], ["Accounts Receivable", "$50,000"], ["Inventory", "$75,000"], ["Total Current Assets", "=SUM(C3:C5)"], ["Fixed Assets", ""], ["Property, Plant, and Equipment", "$200,000"], ["Less: Accumulated Depreciation", "($50,000)"], ["Net Fixed Assets", "=B8-B9"], ["Total Assets", "=B6+B10"], ["Liabilities and Equity", ""], ["Current Liabilities", ""], ["Accounts Payable", "$30,000"], ["Short-term Loans", "$20,000"], ["Total Current Liabilities", "=SUM(C14:C15)"], ["Long-term Liabilities", ""], ["Bank Loans", "$100,000"], ["Total Liabilities", "=B16+B18"], ["Owner's Equity", ""], ["Capital", "$200,000"], ["Retained Earnings", "$50,000"], ["Total Equity", "=B20+B21"], ["Total Liabilities and Equity", "=B17+B22"], ] # Add balance sheet data to the worksheet for row in balance_sheet_data: sheet.append(row) # Apply formatting to header cells header_font = Font(bold=True) for row in sheet.iter_rows(min_row=1, max_row=2): for cell in row: cell.font = header_font # Save the workbook file_name = "balance_sheet.xlsx" # Replace with your desired file name workbook.save(file_name) # Close the workbook workbook.close()