from pathlib import Path import pandas as pd output = Path("exports/orders.xlsx") output.parent.mkdir(parents=True, exist_ok=True) orders = pd.DataFrame( { "order_id": pd.Series(["A100", "A101", "A102"], dtype="string"), "customer": ["Ada Lovelace", "Lin Chen", "Maya Patel"], "region": ["EMEA", "APAC", "AMER"], "total_usd": [149.5, None, 212.0], "ordered_at": pd.to_datetime( ["2026-06-01", "2026-06-02", "2026-06-03"] ), "internal_note": ["priority", "review", "standard"], } ) export_columns = ["order_id", "customer", "region", "total_usd", "ordered_at"] orders.to_excel( output, sheet_name="Orders", columns=export_columns, index=False, na_rep="", float_format="%.2f", freeze_panes=(1, 0), autofilter=True, engine="openpyxl", ) print(f"Wrote {output}") print("Sheet: Orders") print(f"Rows: {len(orders)}") print(f"Columns: {', '.join(export_columns)}")