[{"data":1,"prerenderedAt":400},["ShallowReactive",2],{"topic:writing-excel":3},[4,13,20,27,32,38,43,48,54,60,66,72,78,83,89,95,100,106,111,116,121,127,132,140,145,150,157,162,169,175,181,187,192,197,202,207,212,217,222,227,232,237,242,247,252,257,262,267,272,278,283,289,294,299,304,309,314,319,324,329,335,340,345,350,355,360,365,370,375,380,385,390,395],{"path":5,"title":6,"description":7,"type":8,"topics":9,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Freorder-columns-to-match-a-template-layout-with-pandas","Reorder Columns to Match a Template Layout with pandas","Make every incoming file match the column layout a template, upload form or downstream system expects: read the required order from the template itself, map renamed headers, reindex so columns land in the right place, decide what happens to missing and extra columns, check the result, and write the data under the template's own header row without disturbing its formatting.","how-to",[10,11],"data-cleaning","writing-excel",null,{"path":14,"title":15,"description":16,"type":8,"topics":17,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcreating-pivot-tables-from-excel-data\u002Fexport-pandas-pivot-table-to-excel-formatted","Export a Pandas Pivot Table to Excel (Formatted)","Build a pandas pivot_table, flatten its MultiIndex, export with to_excel, then add a styled header, number formats, and a grand-total row with openpyxl.",[18,11,19],"pivots-and-summaries","pandas",{"path":21,"title":22,"description":23,"type":8,"topics":24,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fmerging-and-joining-excel-dataframes\u002Fappend-new-rows-to-a-master-excel-file-without-duplicates","Append New Rows to a Master Excel File Without Duplicates","Weekly extracts overlap — the same invoices appear in this week's file and last week's — and appending them blindly fills the master workbook with duplicates. Find genuinely new rows with a key-based anti-join, decide what to do with rows that changed, append with openpyxl so the master's formatting and table survive, keep reruns idempotent, and log every run.",[25,26,11],"joins-and-lookups","sheets-and-files",{"path":28,"title":29,"description":30,"type":8,"topics":31,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fmerging-and-joining-excel-dataframes\u002Fupdate-one-excel-file-from-another-with-pandas","Update One Excel File from Another with pandas","Apply a changes file to a master list — new prices, corrected emails, customers added — the way people do with copy-paste and VLOOKUP. Compare DataFrame.update, combine_first and an explicit upsert, keep a change log of old and new values, and write the updates into the existing workbook without destroying its formatting.",[25,11,19],{"path":33,"title":34,"description":35,"type":8,"topics":36,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fmoving-data-between-excel-and-databases\u002Fexport-sql-query-results-to-excel-with-python","Export SQL Query Results to Excel with Python","Run a parameterised query with SQLAlchemy and write the result to a formatted workbook: one sheet per result set, correct date and money formats, sized columns, and chunked reads for big results.",[37,11,19],"data-sources",{"path":39,"title":40,"description":41,"type":8,"topics":42,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fmoving-data-between-excel-and-databases\u002Ffetch-api-data-into-excel-with-python-requests","Fetch API Data into Excel with Python requests","Pull JSON from an HTTP API into a workbook: a session with timeouts and retries, pagination that terminates, json_normalize for nested records, and a cache so a rerun does not hammer the endpoint.",[37,11],{"path":44,"title":45,"description":46,"type":8,"topics":47,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fmoving-data-between-excel-and-databases\u002Fgenerate-sql-insert-statements-from-an-excel-sheet","Generate SQL INSERT Statements from an Excel Sheet","Turn an Excel sheet into a reviewable .sql script for a database administrator to run: map pandas types to SQL literals, quote text safely by doubling single quotes, write NULL for blanks, dates as ISO literals, batch rows into multi-row INSERTs inside one transaction, add an upsert variant for PostgreSQL, and prove the script by running it against a scratch database and comparing every value with the sheet.",[37,11],{"path":49,"title":50,"description":51,"type":8,"topics":52,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Freading-excel-with-polars-and-arrow\u002Fwrite-a-polars-dataframe-to-excel-with-formatting","Write a Polars DataFrame to Excel with Formatting","Use DataFrame.write_excel to produce a formatted workbook: number formats, autofit, Excel tables, conditional formats, multiple sheets, totals rows and charts.",[53,11],"polars",{"path":55,"title":56,"description":57,"type":8,"topics":58,"kind":12},"\u002Fadvanced-data-transformation-and-cleaning\u002Fworking-with-large-excel-files-in-python\u002Fwrite-large-dataframes-to-excel-with-write-only-mode","Write Large DataFrames to Excel with write_only Mode","Generate hundred-thousand-row workbooks without the memory — openpyxl write_only, xlsxwriter constant_memory, streaming a DataFrame row by row, and the formatting you must plan ahead.",[59,11,19],"large-files",{"path":61,"title":62,"description":63,"type":8,"topics":64,"kind":12},"\u002Fautomating-reporting-workflows\u002Fautomating-excel-online-with-microsoft-graph\u002Fappend-rows-to-an-excel-online-table-with-microsoft-graph","Append Rows to an Excel Online Table with Microsoft Graph","Add new records to an Excel table in OneDrive or SharePoint without downloading the file: match columns to the table header, skip rows already present, send rows in batches, and retry safely.",[65,11],"excel-online",{"path":67,"title":68,"description":69,"type":8,"topics":70,"kind":12},"\u002Fautomating-reporting-workflows\u002Fautomating-excel-online-with-microsoft-graph\u002Fread-and-write-excel-online-ranges-with-microsoft-graph","Read and Write Excel Online Ranges with Microsoft Graph","Edit a workbook in OneDrive or SharePoint in place: read a range or the used range into pandas, write a DataFrame back with the right address, send dates and number formats correctly, and avoid the null-means-skip trap.",[65,71,11],"reading-excel",{"path":73,"title":74,"description":75,"type":8,"topics":76,"kind":12},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fadd-summary-sheet-to-excel-report-python","Add a Summary Sheet to an Excel Report with Python","Compute KPIs with pandas groupby, write a styled Summary sheet first, then detail sheets, and make the Summary the active leftmost tab — all with openpyxl.",[77,11],"report-layouts",{"path":79,"title":80,"description":81,"type":8,"topics":82,"kind":12},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fwrite-multiple-dataframes-to-one-excel-file","Write Multiple DataFrames to One Excel File","Write several pandas DataFrames into one .xlsx: separate sheets via one ExcelWriter, stacking on a single sheet with startrow, and appending with mode='a'.",[11,26,19],{"path":84,"title":85,"description":86,"type":8,"topics":87,"kind":12},"\u002Fautomating-reporting-workflows\u002Ferror-handling-and-logging-in-excel-automation\u002Fhandle-permission-denied-when-writing-excel-in-python","Handle Permission Denied When Writing Excel in Python","Why openpyxl raises PermissionError when a workbook is open in Excel, how to detect the lock file, retry sensibly, fall back to a timestamped name, and avoid the problem entirely.",[88,11],"troubleshooting",{"path":90,"title":91,"description":92,"type":8,"topics":93,"kind":12},"\u002Fautomating-reporting-workflows\u002Ferror-handling-and-logging-in-excel-automation\u002Fprevent-formula-injection-in-excel-exports","Prevent Formula Injection in Excel Exports from Python","User-supplied text that starts with \"=\" becomes a live formula when an export writes it to Excel: openpyxl, xlsxwriter and pandas all do this by default. Find which writers turn strings into formulas, store data as text in .xlsx files, neutralise dangerous prefixes in CSV exports, and test that no data cell ever becomes a formula.",[94,11],"reliable-jobs",{"path":96,"title":97,"description":98,"type":8,"topics":99,"kind":12},"\u002Fautomating-reporting-workflows\u002Ferror-handling-and-logging-in-excel-automation\u002Fwrite-excel-files-atomically-in-python","Write Excel Files Atomically in Python","Never leave a half-written workbook behind: why saving straight over report.xlsx can corrupt it when a script crashes or a reader opens it mid-write, the write-to-temp-then-os.replace pattern as a reusable context manager for openpyxl, pandas and XlsxWriter, validating before the swap, keeping permissions, and what changes on Windows, network shares and sync folders.",[94,11],{"path":101,"title":102,"description":103,"type":8,"topics":104,"kind":12},"\u002Fautomating-reporting-workflows\u002Fserving-excel-files-from-python-web-apps\u002Fbuild-an-excel-workbook-in-memory-with-bytesio","Build an Excel Workbook in Memory with BytesIO","Create .xlsx entirely in memory with pandas, xlsxwriter or openpyxl: the close-and-seek rules, in_memory mode, sending bytes to S3 or email, and reading them back.",[105,11],"web-apps",{"path":107,"title":108,"description":109,"type":8,"topics":110,"kind":12},"\u002Fautomating-reporting-workflows\u002Fserving-excel-files-from-python-web-apps\u002Fdownload-an-excel-file-from-a-dash-app","Download an Excel File from a Dash App","Add an \"Export to Excel\" button to a Plotly Dash dashboard: dcc.Download with a callback that sends exactly the data the user filtered, a formatted multi-sheet workbook built in memory, a sensible file name, unit tests that call the callback and open the workbook it returns, and a Flask route on the Dash server for exports too large to send through a callback.",[105,11],{"path":112,"title":113,"description":114,"type":8,"topics":115,"kind":12},"\u002Fautomating-reporting-workflows\u002Fserving-excel-files-from-python-web-apps\u002Fexport-a-django-queryset-to-excel","Export a Django Queryset to Excel","Turn a Django queryset into a formatted .xlsx download: values() and related fields, iterator() for large exports, permissions, admin actions and a view test.",[105,11],{"path":117,"title":118,"description":119,"type":8,"topics":120,"kind":12},"\u002Fautomating-reporting-workflows\u002Ftesting-and-packaging-excel-automation-scripts\u002Fmake-excel-output-reproducible","Make Excel Output Reproducible in Python","Run the same report twice on the same inputs and get byte-identical workbooks. Find what changes between runs — the created and modified timestamps inside the file, zip entry dates, unsorted inputs, sets, random numbers and the clock — fix each one for xlsxwriter and openpyxl, and prove it with a hash check in a test.",[94,11],{"path":122,"title":123,"description":124,"type":8,"topics":125,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fformat-zip-codes-and-ids-with-leading-zeros","Format ZIP Codes and IDs with Leading Zeros in Excel","Write ZIP codes, employee numbers and account codes to Excel so 02134 stays 02134. Choose between storing them as text and storing numbers with a zero-padding format, write both ways with pandas, openpyxl and xlsxwriter, handle 5- and 9-digit ZIPs in one column, add prefixes and phone-style patterns, and avoid the lookup mismatches each choice can cause.",[126,11],"number-formats",{"path":128,"title":129,"description":130,"type":8,"topics":131,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fwrite-custom-number-format-codes-in-excel-with-python","Write Custom Number Format Codes in Excel with Python","The four-section format language explained: dashes for zero, red parenthesised negatives, thousands scaling with a trailing comma, literal units — all without changing the stored value.",[126,11],{"path":133,"title":134,"description":135,"type":136,"topics":137,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter","Building Excel Reports with xlsxwriter","The write-only engine that formats fastest: reusable format objects, column-level formatting, charts, conditional formats, panes and constant-memory mode — and exactly when openpyxl is still the right choice.","guide",[138,11,139],"xlsxwriter","cell-styling",{"path":141,"title":142,"description":143,"type":8,"topics":144,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter\u002Fwrite-a-formatted-excel-report-with-xlsxwriter","Write a Formatted Excel Report with xlsxwriter","Build a complete styled report in one pass: a title block, a header row you control, column formats and widths, a totals row, banded rows, an autofilter and frozen panes.",[11,138,139],{"path":146,"title":147,"description":148,"type":8,"topics":149,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter\u002Fwrite-a-million-rows-to-excel-with-xlsxwriter-constant-memory","Write a Million Rows to Excel with xlsxwriter","Constant memory mode explained: what it costs, why rows must be written in order, where the temporary files go, how to split past Excel's 1,048,576-row limit, and when a CSV is the honest answer.",[59,11,138],{"path":151,"title":152,"description":153,"type":8,"topics":154,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fadd-line-chart-to-excel-report-with-python","Add a Line Chart to an Excel Report with Python","Add an editable line chart to an Excel report with openpyxl: write time-series data, plot multiple series, set a date x-axis, add markers, label axes, and anchor it.",[155,11,156],"charts-and-images","openpyxl",{"path":158,"title":159,"description":160,"type":8,"topics":161,"kind":12},"\u002Fformatting-and-charting-excel-reports-with-python\u002Finserting-images-and-logos-into-excel\u002Fadd-logo-image-to-excel-report-with-openpyxl","Add a Logo Image to an Excel Report with openpyxl","Step-by-step openpyxl guide to add a logo to an Excel report: create the image, anchor it at A1, size it to a header band, add a merged title, and save.",[155,11,156],{"path":163,"title":164,"description":165,"type":166,"topics":167,"kind":12},"\u002Fgetting-started-with-python-excel-automation","Getting Started with Python Excel Automation","Learn how to read, transform, and write Excel files with Python using pandas and openpyxl — the libraries, the pipeline pattern, and runnable starter code.","overview",[168,71,11],"choosing-libraries",{"path":170,"title":171,"description":172,"type":8,"topics":173,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fautomating-excel-with-com-and-pywin32\u002Fread-and-write-cell-ranges-with-win32com","Read and Write Cell Ranges with win32com","Move data between Python and Excel in single calls: block reads, the nested shape writes require, sizing ranges with End(xlUp), and Value versus Value2.",[174,71,11],"com-automation",{"path":176,"title":177,"description":178,"type":8,"topics":179,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fautomating-excel-with-xlwings-basics\u002Fread-and-write-a-live-excel-workbook-with-xlwings","Read and Write a Live Excel Workbook with xlwings","Drive the open application rather than the file: connect to a running workbook, read and write ranges, force a recalculation, read what the formulas produced, and clean up so no invisible Excel is left behind.",[180,71,11],"xlwings",{"path":182,"title":183,"description":184,"type":8,"topics":185,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fconvert-csv-files-to-excel-with-python","Convert CSV Files to Excel with Python","Turn CSV exports into proper Excel workbooks — detect the encoding and delimiter, keep IDs as text, parse dates, combine many CSVs into one workbook with a sheet each, split files larger than Excel's row limit, and format the result.",[186,11,19],"file-formats",{"path":188,"title":189,"description":190,"type":8,"topics":191,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fconvert-word-document-tables-to-excel-with-python","Convert Word Document Tables to Excel with Python","Pull every table out of a .docx file into a workbook with python-docx and pandas: one sheet per table named after the heading above it, merged cells that python-docx repeats, line breaks inside cells, prices and percentages stored as text, a whole folder of documents, and old .doc files.",[186,11],{"path":193,"title":194,"description":195,"type":8,"topics":196,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-and-write-ods-files-with-python","Read and Write .ods Files with Python","Handle OpenDocument spreadsheets from Python with pandas and odfpy — reading sheets, writing output, the formatting limits, and converting .ods to .xlsx when you need more.",[186,71,11],{"path":198,"title":199,"description":200,"type":8,"topics":201,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fwrite-csv-files-that-open-correctly-in-excel","Write CSV Files That Open Correctly in Excel","A CSV that looks fine in a text editor can open in Excel with garbled accents, everything crammed into column A, IDs stripped of leading zeros and long numbers in scientific notation. Write it with a UTF-8 byte order mark, the separator and decimal mark the reader's Excel expects, ISO dates, protected identifiers and safe quoting — or decide that the file should really be an .xlsx.",[186,11],{"path":203,"title":204,"description":205,"type":8,"topics":206,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-cannot-convert-to-excel-valueerror","Fix \"ValueError: Cannot convert to Excel\" in openpyxl","openpyxl accepts only values Excel can store — numbers, text, booleans, dates, None. Lists, dicts, sets, UUIDs and pandas' NA raise \"Cannot convert … to Excel\". Find the offending values, convert them deliberately, and write DataFrames without surprises.",[88,11,156],{"path":208,"title":209,"description":210,"type":8,"topics":211,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-excel-file-format-or-extension-is-not-valid","Fix \"Excel Cannot Open the File Because the File Format or Extension Is Not Valid\"","Excel refuses a file your Python script produced when its bytes do not match its .xlsx name: CSV or HTML saved under an Excel extension, a writer that was never closed, bytes mangled in text mode, or a macro workbook saved as .xlsx. Diagnose which one with a short checker and fix the writing code.",[88,11,186],{"path":213,"title":214,"description":215,"type":8,"topics":216,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-excel-repaired-content-after-writing-with-python","Fix \"Excel Found Unreadable Content\" After Writing with Python","Your script saved a workbook and Excel offers to repair it. The rules Excel enforces — sheet names, table names, defined names, timezones — and how to satisfy them.",[88,11,156],{"path":218,"title":219,"description":220,"type":8,"topics":221,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-excelwriter-has-no-attribute-save","Fix \"ExcelWriter object has no attribute save\" in pandas","pandas 2.0 removed ExcelWriter.save(), so old scripts fail with AttributeError. Replace it with a with block or close(), and fix the other removed writer APIs that usually break at the same time — book assignment, sheets assignment and handles.",[88,11,19],{"path":223,"title":224,"description":225,"type":8,"topics":226,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-illegalcharactererror-when-writing-excel-with-openpyxl","Fix IllegalCharacterError When Writing Excel with openpyxl","openpyxl refuses to write text containing control characters such as \\x00 or a vertical tab. Find which cells hold them, decide what each character should become, and clean the data so the write succeeds.",[88,11,156],{"path":228,"title":229,"description":230,"type":8,"topics":231,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-invalid-worksheet-name-errors","Fix Invalid Worksheet Name Errors When Writing Excel","Sheet names built from data — regions, customers, dates — break Excel's rules: 31 characters at most, none of [ ] : * ? \u002F \\, no leading or trailing apostrophe, unique regardless of case. See what openpyxl, xlsxwriter and pandas do with each rule and write one function that makes any name safe.",[88,26,11],{"path":233,"title":234,"description":235,"type":8,"topics":236,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-long-id-numbers-losing-digits-in-excel","Fix Long ID Numbers Losing Digits or Turning into 1.23E+18 in Excel","Account numbers, card numbers and 18-digit IDs lose their last digits when written to Excel as numbers — Python writers keep 16 significant digits and Excel keeps 15. Write identifiers as text, read them back as text, and stop the leading zeros and trailing digits from changing.",[88,11,126],{"path":238,"title":239,"description":240,"type":8,"topics":241,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-number-stored-as-text-warnings-in-excel-output","Fix \"Number Stored as Text\" Warnings in Excel Output","Green triangles all over a workbook your script wrote mean numbers went in as strings. Convert them to real numbers before writing, keep identifiers as text on purpose, and silence the warning where text is correct.",[88,126,11],{"path":243,"title":244,"description":245,"type":8,"topics":246,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-sheet-already-exists-errors-in-pandas-excelwriter","Fix \"Sheet Already Exists\" Errors in pandas ExcelWriter","Fix ValueError: Sheet 'Summary' already exists and if_sheet_exists is set to 'error' when writing to an existing workbook with pandas: what each if_sheet_exists option really does — error, new, replace and overlay — why overlay leaves old rows behind, the related \"Append mode is not supported with xlsxwriter\" error, and a safe way to refresh one sheet of a workbook.",[88,11],{"path":248,"title":249,"description":250,"type":8,"topics":251,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-text-truncated-at-32767-characters-in-excel","Fix Text Truncated at 32,767 Characters in Excel Output","An Excel cell holds at most 32,767 characters, and Python writers enforce it differently: openpyxl cuts long text silently, xlsxwriter returns -2, pandas warns. Find the long values before writing, make truncation an error, and keep the full text by splitting it across cells, linking to a file, or choosing another format.",[88,11],{"path":253,"title":254,"description":255,"type":8,"topics":256,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-valueerror-io-operation-on-closed-file-with-excelwriter","Fix \"ValueError: I\u002FO operation on closed file\" with ExcelWriter","pandas raises \"ValueError: I\u002FO operation on closed file\" when an ExcelWriter or the buffer it wrote to is used after it was closed: a file handle whose with block ended before the writer, a BytesIO returned from inside its own with block, or a buffer read after close. Reproduce each case, see why the file ends up empty, fix the order of the blocks, and catch the silent variant where writing after the with block loses a sheet without any error.",[88,11],{"path":258,"title":259,"description":260,"type":8,"topics":261,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-wrong-sheet-order-after-writing-with-pandas","Fix Wrong Sheet Order After Writing with pandas","Sheets come out as Apr, Aug, Dec, Feb… or the summary ends up last after appending to a workbook. Find which of the usual causes applies — alphabetical group keys, sets and unsorted dictionaries, sheets appended to an existing file — write the sheets in the order you want, or reorder an existing workbook with openpyxl, set the sheet that opens first, and check the final order in a test.",[88,11],{"path":263,"title":264,"description":265,"type":8,"topics":266,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-xlsxwriter-overwriting-an-existing-workbook","Fix XlsxWriter Overwriting an Existing Workbook","You pointed XlsxWriter — or pandas with its default engine — at an existing workbook to add a sheet, and every other sheet vanished. XlsxWriter only creates new files and never reads old ones. See why, what \"Append mode is not supported with xlsxwriter!\" means, how to add or replace a sheet with openpyxl's append mode and if_sheet_exists, and how to guard against overwriting a file by accident.",[88,138,11],{"path":268,"title":269,"description":270,"type":136,"topics":271,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation","Using openpyxl for Excel File Manipulation","A runnable, step-by-step guide to creating, reading, editing, styling, and saving .xlsx files with openpyxl — workbooks, sheets, cells, formatting, and images.",[156,71,11],{"path":273,"title":274,"description":275,"type":8,"topics":276,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Fconvert-column-letters-and-numbers-with-openpyxl","Convert Excel Column Letters and Numbers in Python","Turn 28 into \"AB\" and \"XFD\" into 16384 with openpyxl's get_column_letter and column_index_from_string, parse cell and range addresses, and map DataFrame columns to letters for formulas — plus why naive base-26 code breaks at Z and the 0-based\u002F1-based traps between pandas, openpyxl and xlsxwriter.",[156,277,11],"excel-formulas",{"path":279,"title":280,"description":281,"type":8,"topics":282,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Ffind-and-replace-text-in-excel-with-openpyxl","Find and Replace Text in Excel with openpyxl","Replace a company name, a product code or a year across every sheet of a workbook without losing formatting: plain and regex replacement, formulas left intact, rich text preserved, and a log of every change.",[11,156],{"path":284,"title":285,"description":286,"type":8,"topics":287,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Fhow-openpyxl-stores-python-values-in-cells","How openpyxl Stores Python Values: Types, Dates and None","What happens to an int, a bool, a date, a Decimal, a NumPy value or a timezone-aware datetime when you assign it to an openpyxl cell — the cell type it becomes, the number format it gets, what comes back when the file is reopened, and which values fail only when you save.",[156,11,288],"dates-and-times",{"path":290,"title":291,"description":292,"type":8,"topics":293,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Finsert-and-delete-rows-and-columns-with-openpyxl","Insert and Delete Rows and Columns with openpyxl","Add and remove rows and columns in an existing Excel file with openpyxl — insert_rows, delete_cols, why formulas and merges do not move, and safe deletion in reverse order.",[11,156],{"path":295,"title":296,"description":297,"type":8,"topics":298,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Fopenpyxl-append-data-to-existing-excel-sheet","openpyxl: Append Data to an Existing Excel Sheet","Add new rows to an existing .xlsx file with openpyxl — using ws.append(), explicit row indexing, dict-based sparse appends, type-safe values, and atomic saves.",[11,156],{"path":300,"title":301,"description":302,"type":8,"topics":303,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Fwhat-openpyxl-loses-when-saving-an-existing-workbook","What openpyxl Loses When You Save an Existing Workbook","openpyxl rewrites the whole file when it saves, and features it does not model disappear — sparklines, shapes and text boxes, data-bar and validation extensions, macros, slicers. Tested list, a pre-save risk scan, and safer alternatives.",[88,11,156],{"path":305,"title":306,"description":307,"type":8,"topics":308,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fworking-with-excel-formulas-in-python\u002Fwrite-formula-to-excel-cell-with-openpyxl","Write a Formula to an Excel Cell with openpyxl","Assign a formula string to a cell with openpyxl, avoid the Text-format trap that shows the formula instead of a result, and verify what actually landed in the file.",[277,11,156],{"path":310,"title":311,"description":312,"type":8,"topics":313,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fworking-with-multiple-excel-sheets-in-python\u002Fcreate-a-sheet-for-each-group-in-a-dataframe","Create a Sheet for Each Group in a DataFrame","Split one DataFrame into one worksheet per region, customer or month with groupby and ExcelWriter — with safe sheet names, a contents sheet, consistent formatting, and the silent overwrite trap when two groups map to the same name.",[26,11,19],{"path":315,"title":316,"description":317,"type":136,"topics":318,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas","Writing DataFrames to Excel with Pandas","Export pandas DataFrames to Excel: single and multi-sheet workbooks, number and date formats, appending to existing files, and choosing the right engine.",[11,19],{"path":320,"title":321,"description":322,"type":8,"topics":323,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fappend-a-dataframe-to-an-existing-excel-file-with-pandas","Append a DataFrame to an Existing Excel File with pandas","Add rows or a new sheet to a workbook that already exists — ExcelWriter mode 'a', if_sheet_exists options, appending below existing data, and the openpyxl-only limits.",[11,19],{"path":325,"title":326,"description":327,"type":8,"topics":328,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fauto-fit-column-widths-when-writing-with-pandas","Auto-Fit Column Widths When Writing with pandas","Stop Excel reports opening with ##### and truncated headers — measure content width in Python and set column widths with xlsxwriter or openpyxl, including a reusable helper.",[139,11,19],{"path":330,"title":331,"description":332,"type":8,"topics":333,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fcontrol-how-nan-and-infinity-appear-in-excel-output","Control How NaN, None and Infinity Appear in Excel Output","pandas writes NaN, None, pd.NA and NaT as empty cells and infinity as the text \"inf\". Learn what each choice does to Excel formulas, when na_rep and inf_rep help or hurt, and how to handle division-by-zero results and placeholders column by column.",[11,334,19],"missing-data",{"path":336,"title":337,"description":338,"type":8,"topics":339,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fexport-a-styled-pandas-dataframe-to-excel","Export a Styled pandas DataFrame to Excel","Use pandas Styler to colour, bold and highlight a DataFrame, then write it to Excel with the styles intact — and learn which Styler features survive the trip, including why format() does not and what to use instead.",[139,11,19],{"path":341,"title":342,"description":343,"type":8,"topics":344,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fhow-pandas-data-types-are-written-to-excel-cells","How pandas Data Types Are Written to Excel Cells","What to_excel actually stores for each pandas dtype — integers, nullable types, floats, booleans, text, datetime64, date objects, timedeltas, categoricals, Decimal, infinity, Period, lists and timezone-aware timestamps — checked cell by cell with openpyxl, plus the conversions to apply before writing so the workbook holds what you meant.",[11,19],{"path":346,"title":347,"description":348,"type":8,"topics":349,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fopenpyxl-vs-xlsxwriter-vs-pandas-excelwriter","openpyxl vs xlsxwriter vs pandas.ExcelWriter","Understand how pandas.ExcelWriter wraps the openpyxl and xlsxwriter engines, when each one wins, and write the same DataFrame three ways with a clear decision table.",[168,11,138,156,19],{"path":351,"title":352,"description":353,"type":8,"topics":354,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fround-numbers-for-excel-output-float-format-vs-number-formats","Round Numbers for Excel Output: float_format vs Number Formats","pandas offers three ways to get two decimal places into Excel — to_excel's float_format, DataFrame.round and a cell number format — and they do different things. See which one changes the stored value, which one changes only the display, and why they disagree on halves like 0.015.",[11,126,19],{"path":356,"title":357,"description":358,"type":8,"topics":359,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel","Write a DataFrame to a Specific Cell in Excel with pandas","Place a DataFrame at B5 instead of A1 — with startrow and startcol, into a new file or into an existing template without wiping its title, formatting and notes — and know when to drop down to openpyxl.",[11,19],{"path":361,"title":362,"description":363,"type":8,"topics":364,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-list-of-dictionaries-to-excel-without-pandas","Write a List of Dictionaries to Excel Without pandas","Write records from an API, a database cursor or your own code straight to .xlsx with openpyxl: a header from the union of keys, missing keys left blank, nested values flattened, dates and decimals kept as real Excel types, write-only mode for large lists, and a formatted table at the end.",[11,156],{"path":366,"title":367,"description":368,"type":8,"topics":369,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-multiindex-dataframe-to-excel","Write a MultiIndex DataFrame to Excel with pandas","Write pivot tables and grouped results with MultiIndex rows or columns to Excel — merged or repeated labels, the extra index-name row, the index=False error, flattening for filters, and reading it back.",[11,18,19],{"path":371,"title":372,"description":373,"type":8,"topics":374,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-clickable-links-from-a-dataframe-to-excel","Write Clickable Links from a DataFrame Column to Excel","Turn a column of URLs into clickable links when writing a DataFrame to Excel: rely on xlsxwriter's automatic URL detection, write HYPERLINK formulas with friendly text, or set cell.hyperlink with openpyxl. Covers link text, internal sheet links, URL length limits and formula injection.",[11,139,19],{"path":376,"title":377,"description":378,"type":8,"topics":379,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-dates-without-time-from-pandas-to-excel","Write Dates Without the Time Part from pandas to Excel","pandas writes datetime columns with a YYYY-MM-DD HH:MM:SS format, so every date shows 00:00:00. Write real dates that display as dates: convert to date objects, set datetime_format on an xlsxwriter ExcelWriter, or apply a number format per column — and avoid the openpyxl engine option that is silently ignored.",[11,288,126],{"path":381,"title":382,"description":383,"type":8,"topics":384,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-excel-formulas-from-a-pandas-dataframe","Write Excel Formulas from a pandas DataFrame","Put live formulas into a sheet written with to_excel: build formula strings per row, look up column letters by name so the formulas survive column changes, account for the header, index and startrow offsets, add a totals row, understand why the results read back as 0 or NaN until the file is recalculated, and turn the formula conversion off for text that merely starts with \"=\".",[11,277,19],{"path":386,"title":387,"description":388,"type":8,"topics":389,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-grouped-data-with-blank-rows-between-groups","Write Grouped Data with Blank Rows Between Groups","Write a pandas DataFrame to Excel as a readable grouped report — a heading row for each group, its detail rows, a subtotal row with a live SUBTOTAL formula and a blank row before the next group — by planning the row positions first and writing once, instead of inserting rows afterwards; add a grand total that does not double count, optional outline levels, and check the formulas recalculate correctly.",[11,77],{"path":391,"title":392,"description":393,"type":8,"topics":394,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-pandas-dataframe-to-excel-without-index","Write a Pandas DataFrame to Excel Without the Index","Pass index=False to to_excel() to drop pandas row numbers from your spreadsheet — plus how it behaves with a MultiIndex, append mode, and a quick output check.",[11,19],{"path":396,"title":397,"description":398,"type":8,"topics":399,"kind":12},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-very-wide-dataframes-to-excel","Write Very Wide DataFrames to Excel","Excel stops at 16,384 columns. pandas raises \"This sheet is too large!\" above that — but only checks the DataFrame itself, so a frame that fits exactly loses its last column silently when the index is written. Detect the real width, then choose a fix: transpose short-and-wide data, reshape to long format with melt, or split the columns across several sheets with the key repeated on each, and check what was written.",[11,88],1790972052270]