[{"data":1,"prerenderedAt":2540},["ShallowReactive",2],{"doc:\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel":3,"surround:\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel":2507,"ancestors:\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel":2516,"children:\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel":2521,"related:\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel":2522},{"id":4,"title":5,"body":6,"dateModified":2473,"datePublished":2473,"description":2474,"extension":2475,"faq":2476,"keyword":2485,"kind":2486,"meta":2487,"navigation":391,"path":2496,"seo":2497,"slug":2500,"stem":2501,"topics":2502,"type":2505,"__hash__":2506},"docs\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel\u002Findex.md","Write a DataFrame to a Specific Cell in Excel with pandas",{"type":7,"value":8,"toc":2459},"minimark",[9,31,327,332,363,481,485,492,636,651,654,774,778,785,1105,1111,1272,1278,1282,1289,1377,1384,1388,1391,1754,1761,1765,1768,1932,1950,2010,2014,2030,2305,2312,2316,2367,2371,2374,2378,2394,2398,2404,2410,2416,2422,2426,2455],[10,11,12,16,17,20,21,24,25,30],"p",{},[13,14,15],"code",{},"df.to_excel()"," puts the header in cell A1 by default, which is right for a data dump and wrong for almost any report. Reports have a title in the top rows, a date or a note beside the table, sometimes two tables on one sheet — and very often an existing template whose layout someone designed by hand. pandas handles all of these with two arguments, ",[13,18,19],{},"startrow"," and ",[13,22,23],{},"startcol",", plus one writer setting that decides whether the rest of the sheet survives. This guide is part of ",[26,27,29],"a",{"href":28},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002F","Writing DataFrames to Excel with Pandas",".",[32,33,41,42,41,46,41,50,41,58,41,68,41,73,41,84,41,91,41,97,41,100,41,106,41,110,41,114,41,118,41,122,41,126,41,130,41,134,41,138,41,142,41,147,41,152,41,157,41,159,41,162,41,166,41,168,41,170,41,172,41,174,41,176,41,180,41,183,41,187,41,189,41,191,41,193,41,195,41,197,41,200,41,204,41,206,41,208,41,210,41,212,41,214,41,217,41,221,41,223,41,227,41,231,41,233,41,236,41,238,41,241,41,243,41,246,41,250,41,252,41,254,41,258,41,260,41,263,41,265,41,268,41,270,41,273,41,277,41,279,41,281,41,284,41,286,41,289,41,291,41,294,41,296,41,299,41,302,41,304,41,306,41,309,41,311,41,314,41,316,41,319,41,321],"svg",{"viewBox":34,"role":35,"ariaLabelledBy":36,"xmlns":39,"style":40},"111 0 537 336","img",[37,38],"cell-offset-t","cell-offset-d","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;max-width:537px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif","\n  ",[43,44,45],"title",{"id":37},"A DataFrame written with startrow=4 and startcol=1",[47,48,49],"desc",{"id":38},"The report title sits in A1 and a note in E2. The DataFrame header lands in B5 because startrow and startcol are zero-based offsets from A1, and its values fill B6 to D8.",[51,52],"rect",{"x":53,"y":54,"width":55,"height":56,"fill":57},"111","0","537","336","#ffffff",[51,59],{"x":60,"y":61,"width":62,"height":63,"rx":64,"fill":65,"stroke":66,"style":67},"182.9","16.0","394.1","30.0","8","#e7ebef","var(--line,#cdd5e6)","stroke-width:1.5px",[51,69],{"x":60,"y":70,"width":62,"height":71,"rx":54,"fill":65,"stroke":66,"style":72},"38.0","8.0","stroke-width:0px",[74,75,77],"g",{"transform":76},"translate(192.9,23.0) scale(0.667)",[78,79],"path",{"d":80,"fill":81,"stroke":82,"style":83},"M6 3h9l4 4v14H6z M15 3v4h4 M9.5 11.5l4.5 6 M14 11.5l-4.5 6","none","var(--teal-ink,#0b6157)","stroke-width:2.70px;stroke-linecap:round;stroke-linejoin:round",[85,86,90],"text",{"x":87,"y":88,"style":89},"214.9","36.0","font-size:12px;font-weight:700;fill:var(--text,#172033);text-anchor:start","monthly_report.xlsx",[51,92],{"x":60,"y":93,"width":94,"height":95,"rx":54,"fill":65,"stroke":66,"style":96},"46.0","32.0","24.0","stroke-width:1px",[51,98],{"x":87,"y":93,"width":99,"height":95,"rx":54,"fill":65,"stroke":66,"style":96},"44.0",[85,101,105],{"x":102,"y":103,"style":104},"236.9","63.0","font-size:11px;font-weight:600;fill:var(--muted,#5b6780);text-anchor:middle","A",[51,107],{"x":108,"y":93,"width":109,"height":95,"rx":54,"fill":65,"stroke":66,"style":96},"258.9","63.6",[85,111,113],{"x":112,"y":103,"style":104},"290.7","B",[51,115],{"x":116,"y":93,"width":117,"height":95,"rx":54,"fill":65,"stroke":66,"style":96},"322.5","54.8",[85,119,121],{"x":120,"y":103,"style":104},"349.9","C",[51,123],{"x":124,"y":93,"width":125,"height":95,"rx":54,"fill":65,"stroke":66,"style":96},"377.3","74.9",[85,127,129],{"x":128,"y":103,"style":104},"414.8","D",[51,131],{"x":132,"y":93,"width":133,"height":95,"rx":54,"fill":65,"stroke":66,"style":96},"452.2","124.9",[85,135,137],{"x":136,"y":103,"style":104},"514.6","E",[51,139],{"x":60,"y":140,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"70.0","28.0",[85,143,146],{"x":144,"y":145,"style":104},"198.9","89.0","1",[51,148],{"x":87,"y":140,"width":149,"height":141,"rx":54,"fill":150,"stroke":151,"style":67},"237.3","#f0f4ff","var(--brand,#5b5cf0)",[85,153,156],{"x":154,"y":145,"style":155},"333.6","font-size:12px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","Monthly sales report",[51,158],{"x":132,"y":140,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,160],{"x":60,"y":161,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"98.0",[85,163,165],{"x":144,"y":164,"style":104},"117.0","2",[51,167],{"x":87,"y":161,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,169],{"x":108,"y":161,"width":109,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,171],{"x":116,"y":161,"width":117,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,173],{"x":124,"y":161,"width":125,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,175],{"x":132,"y":161,"width":133,"height":141,"rx":54,"fill":65,"stroke":66,"style":67},[85,177,179],{"x":136,"y":164,"style":178},"font-size:12px;font-weight:700;fill:var(--text,#172033);text-anchor:middle","Prepared by ops",[51,181],{"x":60,"y":182,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"126.0",[85,184,186],{"x":144,"y":185,"style":104},"145.0","3",[51,188],{"x":87,"y":182,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,190],{"x":108,"y":182,"width":109,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,192],{"x":116,"y":182,"width":117,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,194],{"x":124,"y":182,"width":125,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,196],{"x":132,"y":182,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,198],{"x":60,"y":199,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"154.0",[85,201,203],{"x":144,"y":202,"style":104},"173.0","4",[51,205],{"x":87,"y":199,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,207],{"x":108,"y":199,"width":109,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,209],{"x":116,"y":199,"width":117,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,211],{"x":124,"y":199,"width":125,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,213],{"x":132,"y":199,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,215],{"x":60,"y":216,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"182.0",[85,218,220],{"x":144,"y":219,"style":104},"201.0","5",[51,222],{"x":87,"y":216,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,224],{"x":108,"y":216,"width":109,"height":141,"rx":54,"fill":225,"stroke":226,"style":67},"#d9f4f1","var(--teal,#0f9488)",[85,228,230],{"x":112,"y":219,"style":229},"font-size:12px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","region",[51,232],{"x":116,"y":216,"width":117,"height":141,"rx":54,"fill":225,"stroke":226,"style":67},[85,234,235],{"x":120,"y":219,"style":229},"units",[51,237],{"x":124,"y":216,"width":125,"height":141,"rx":54,"fill":225,"stroke":226,"style":67},[85,239,240],{"x":128,"y":219,"style":229},"revenue",[51,242],{"x":132,"y":216,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,244],{"x":60,"y":245,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"210.0",[85,247,249],{"x":144,"y":248,"style":104},"229.0","6",[51,251],{"x":87,"y":245,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,253],{"x":108,"y":245,"width":109,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,255,257],{"x":112,"y":248,"style":256},"font-size:12px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","North",[51,259],{"x":116,"y":245,"width":117,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,261,262],{"x":120,"y":248,"style":256},"410",[51,264],{"x":124,"y":245,"width":125,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,266,267],{"x":128,"y":248,"style":256},"12,300",[51,269],{"x":132,"y":245,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,271],{"x":60,"y":272,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"238.0",[85,274,276],{"x":144,"y":275,"style":104},"257.0","7",[51,278],{"x":87,"y":272,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,280],{"x":108,"y":272,"width":109,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,282,283],{"x":112,"y":275,"style":256},"South",[51,285],{"x":116,"y":272,"width":117,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,287,288],{"x":120,"y":275,"style":256},"388",[51,290],{"x":124,"y":272,"width":125,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,292,293],{"x":128,"y":275,"style":256},"11,640",[51,295],{"x":132,"y":272,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,297],{"x":60,"y":298,"width":94,"height":141,"rx":54,"fill":65,"stroke":66,"style":96},"266.0",[85,300,64],{"x":144,"y":301,"style":104},"285.0",[51,303],{"x":87,"y":298,"width":99,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[51,305],{"x":108,"y":298,"width":109,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,307,308],{"x":112,"y":301,"style":256},"East",[51,310],{"x":116,"y":298,"width":117,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,312,313],{"x":120,"y":301,"style":256},"295",[51,315],{"x":124,"y":298,"width":125,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,317,318],{"x":128,"y":301,"style":256},"8,850",[51,320],{"x":132,"y":298,"width":133,"height":141,"rx":54,"fill":57,"stroke":66,"style":96},[85,322,326],{"x":323,"y":324,"style":325},"380.0","316.0","font-size:12.5px;font-weight:400;fill:var(--muted,#5b6780);text-anchor:middle","startrow=4, startcol=1 puts the header in B5 — both offsets count from zero at A1",[328,329,331],"h2",{"id":330},"prerequisites","Prerequisites",[333,334,339],"pre",{"className":335,"code":336,"language":337,"meta":338,"style":338},"language-bash shiki shiki-themes github-light github-dark-high-contrast","pip install pandas openpyxl xlsxwriter\n","bash","",[13,340,341],{"__ignoreMap":338},[342,343,346,350,354,357,360],"span",{"class":344,"line":345},"line",1,[342,347,349],{"class":348},"sMTad","pip",[342,351,353],{"class":352},"srMev"," install",[342,355,356],{"class":352}," pandas",[342,358,359],{"class":352}," openpyxl",[342,361,362],{"class":352}," xlsxwriter\n",[333,364,368],{"className":365,"code":366,"language":367,"meta":338,"style":338},"language-python shiki shiki-themes github-light github-dark-high-contrast","import pandas as pd\n\nsales = pd.DataFrame({\n    \"region\": [\"North\", \"South\", \"East\"],\n    \"units\": [410, 388, 295],\n    \"revenue\": [12300.0, 11640.0, 8850.0],\n})\n","python",[13,369,370,386,393,405,431,452,475],{"__ignoreMap":338},[342,371,372,376,380,383],{"class":344,"line":345},[342,373,375],{"class":374},"s-kum","import",[342,377,379],{"class":378},"skGVy"," pandas ",[342,381,382],{"class":374},"as",[342,384,385],{"class":378}," pd\n",[342,387,389],{"class":344,"line":388},2,[342,390,392],{"emptyLinePlaceholder":391},true,"\n",[342,394,396,399,402],{"class":344,"line":395},3,[342,397,398],{"class":378},"sales ",[342,400,401],{"class":374},"=",[342,403,404],{"class":378}," pd.DataFrame({\n",[342,406,408,411,414,417,420,423,425,428],{"class":344,"line":407},4,[342,409,410],{"class":352},"    \"region\"",[342,412,413],{"class":378},": [",[342,415,416],{"class":352},"\"North\"",[342,418,419],{"class":378},", ",[342,421,422],{"class":352},"\"South\"",[342,424,419],{"class":378},[342,426,427],{"class":352},"\"East\"",[342,429,430],{"class":378},"],\n",[342,432,434,437,439,442,444,446,448,450],{"class":344,"line":433},5,[342,435,436],{"class":352},"    \"units\"",[342,438,413],{"class":378},[342,440,262],{"class":441},"sP0c6",[342,443,419],{"class":378},[342,445,288],{"class":441},[342,447,419],{"class":378},[342,449,313],{"class":441},[342,451,430],{"class":378},[342,453,455,458,460,463,465,468,470,473],{"class":344,"line":454},6,[342,456,457],{"class":352},"    \"revenue\"",[342,459,413],{"class":378},[342,461,462],{"class":441},"12300.0",[342,464,419],{"class":378},[342,466,467],{"class":441},"11640.0",[342,469,419],{"class":378},[342,471,472],{"class":441},"8850.0",[342,474,430],{"class":378},[342,476,478],{"class":344,"line":477},7,[342,479,480],{"class":378},"})\n",[328,482,484],{"id":483},"step-1-offset-the-table-in-a-new-file","Step 1 — Offset the table in a new file",[10,486,487,20,489,491],{},[13,488,19],{},[13,490,23],{}," are zero-based offsets from A1. To leave four rows for a title block and one blank column on the left, put the header at B5:",[333,493,495],{"className":365,"code":494,"language":367,"meta":338,"style":338},"with pd.ExcelWriter(\"monthly_report.xlsx\", engine=\"xlsxwriter\") as writer:\n    sales.to_excel(writer, sheet_name=\"Report\", startrow=4, startcol=1, index=False)\n    sheet = writer.sheets[\"Report\"]\n    sheet.write(\"A1\", \"Monthly sales report\", writer.book.add_format({\"bold\": True, \"font_size\": 14}))\n    sheet.write(\"E2\", \"Prepared by ops\")\n",[13,496,497,527,569,584,622],{"__ignoreMap":338},[342,498,499,502,505,508,510,514,516,519,522,524],{"class":344,"line":345},[342,500,501],{"class":374},"with",[342,503,504],{"class":378}," pd.ExcelWriter(",[342,506,507],{"class":352},"\"monthly_report.xlsx\"",[342,509,419],{"class":378},[342,511,513],{"class":512},"sa561","engine",[342,515,401],{"class":374},[342,517,518],{"class":352},"\"xlsxwriter\"",[342,520,521],{"class":378},") ",[342,523,382],{"class":374},[342,525,526],{"class":378}," writer:\n",[342,528,529,532,535,537,540,542,544,546,548,550,552,554,556,558,561,563,566],{"class":344,"line":388},[342,530,531],{"class":378},"    sales.to_excel(writer, ",[342,533,534],{"class":512},"sheet_name",[342,536,401],{"class":374},[342,538,539],{"class":352},"\"Report\"",[342,541,419],{"class":378},[342,543,19],{"class":512},[342,545,401],{"class":374},[342,547,203],{"class":441},[342,549,419],{"class":378},[342,551,23],{"class":512},[342,553,401],{"class":374},[342,555,146],{"class":441},[342,557,419],{"class":378},[342,559,560],{"class":512},"index",[342,562,401],{"class":374},[342,564,565],{"class":441},"False",[342,567,568],{"class":378},")\n",[342,570,571,574,576,579,581],{"class":344,"line":395},[342,572,573],{"class":378},"    sheet ",[342,575,401],{"class":374},[342,577,578],{"class":378}," writer.sheets[",[342,580,539],{"class":352},[342,582,583],{"class":378},"]\n",[342,585,586,589,592,594,597,600,603,606,609,611,614,616,619],{"class":344,"line":407},[342,587,588],{"class":378},"    sheet.write(",[342,590,591],{"class":352},"\"A1\"",[342,593,419],{"class":378},[342,595,596],{"class":352},"\"Monthly sales report\"",[342,598,599],{"class":378},", writer.book.add_format({",[342,601,602],{"class":352},"\"bold\"",[342,604,605],{"class":378},": ",[342,607,608],{"class":441},"True",[342,610,419],{"class":378},[342,612,613],{"class":352},"\"font_size\"",[342,615,605],{"class":378},[342,617,618],{"class":441},"14",[342,620,621],{"class":378},"}))\n",[342,623,624,626,629,631,634],{"class":344,"line":433},[342,625,588],{"class":378},[342,627,628],{"class":352},"\"E2\"",[342,630,419],{"class":378},[342,632,633],{"class":352},"\"Prepared by ops\"",[342,635,568],{"class":378},[10,637,638,639,642,643,646,647,650],{},"Writing through an ",[13,640,641],{},"ExcelWriter"," rather than a file name is what lets you add the title afterwards: ",[13,644,645],{},"writer.sheets"," gives you the engine's worksheet object for the sheet pandas just created, and ",[13,648,649],{},"writer.book"," the workbook. With the xlsxwriter engine you can then use its whole API — formats, merged titles, column widths — on the same sheet in the same pass.",[10,652,653],{},"Converting an Excel address to offsets is easy to get wrong by one, so let openpyxl do it:",[333,655,657],{"className":365,"code":656,"language":367,"meta":338,"style":338},"from openpyxl.utils.cell import coordinate_from_string, column_index_from_string\n\ndef offsets(address: str) -> tuple[int, int]:\n    letters, row = coordinate_from_string(address)\n    return row - 1, column_index_from_string(letters) - 1\n\nprint(offsets(\"B5\"))    # (4, 1)\nprint(offsets(\"AA10\"))  # (9, 26)\n",[13,658,659,672,676,704,714,736,740,758],{"__ignoreMap":338},[342,660,661,664,667,669],{"class":344,"line":345},[342,662,663],{"class":374},"from",[342,665,666],{"class":378}," openpyxl.utils.cell ",[342,668,375],{"class":374},[342,670,671],{"class":378}," coordinate_from_string, column_index_from_string\n",[342,673,674],{"class":344,"line":388},[342,675,392],{"emptyLinePlaceholder":391},[342,677,678,681,685,688,691,694,697,699,701],{"class":344,"line":395},[342,679,680],{"class":374},"def",[342,682,684],{"class":683},"s_Opv"," offsets",[342,686,687],{"class":378},"(address: ",[342,689,690],{"class":441},"str",[342,692,693],{"class":378},") -> tuple[",[342,695,696],{"class":441},"int",[342,698,419],{"class":378},[342,700,696],{"class":441},[342,702,703],{"class":378},"]:\n",[342,705,706,709,711],{"class":344,"line":407},[342,707,708],{"class":378},"    letters, row ",[342,710,401],{"class":374},[342,712,713],{"class":378}," coordinate_from_string(address)\n",[342,715,716,719,722,725,728,731,733],{"class":344,"line":433},[342,717,718],{"class":374},"    return",[342,720,721],{"class":378}," row ",[342,723,724],{"class":374},"-",[342,726,727],{"class":441}," 1",[342,729,730],{"class":378},", column_index_from_string(letters) ",[342,732,724],{"class":374},[342,734,735],{"class":441}," 1\n",[342,737,738],{"class":344,"line":454},[342,739,392],{"emptyLinePlaceholder":391},[342,741,742,745,748,751,754],{"class":344,"line":477},[342,743,744],{"class":441},"print",[342,746,747],{"class":378},"(offsets(",[342,749,750],{"class":352},"\"B5\"",[342,752,753],{"class":378},"))    ",[342,755,757],{"class":756},"s-wDw","# (4, 1)\n",[342,759,761,763,765,768,771],{"class":344,"line":760},8,[342,762,744],{"class":441},[342,764,747],{"class":378},[342,766,767],{"class":352},"\"AA10\"",[342,769,770],{"class":378},"))  ",[342,772,773],{"class":756},"# (9, 26)\n",[328,775,777],{"id":776},"step-2-write-into-an-existing-template-without-wiping-it","Step 2 — Write into an existing template without wiping it",[10,779,780,781,784],{},"The more common case is a template that already exists: a designed header, a logo, notes, fixed column widths. Opening it with the default writer mode would create a new file and throw all of that away. Append mode with the openpyxl engine and ",[13,782,783],{},"if_sheet_exists=\"overlay\""," writes only the cells the DataFrame covers:",[333,786,788],{"className":365,"code":787,"language":367,"meta":338,"style":338},"from openpyxl import Workbook, load_workbook\nfrom openpyxl.styles import Font\n\ntemplate = Workbook()\nws = template.active\nws.title = \"Report\"\nws[\"A1\"] = \"Monthly sales report\"\nws[\"A1\"].font = Font(bold=True, size=14)\nws[\"E2\"] = \"Prepared by ops\"\nws.column_dimensions[\"B\"].width = 18\ntemplate.save(\"template.xlsx\")\n\nwith pd.ExcelWriter(\"template.xlsx\", mode=\"a\", engine=\"openpyxl\", if_sheet_exists=\"overlay\") as writer:\n    sales.to_excel(writer, sheet_name=\"Report\", startrow=4, startcol=1, index=False)\n\ncheck = load_workbook(\"template.xlsx\")[\"Report\"]\nprint(check[\"A1\"].value, check[\"A1\"].font.b)       # Monthly sales report True\nprint(check[\"B5\"].value, check[\"C6\"].value)        # region 410\nprint(check.column_dimensions[\"B\"].width)          # 18.0\n",[13,789,790,802,814,818,828,838,848,863,895,909,926,937,942,986,1023,1028,1048,1069,1089],{"__ignoreMap":338},[342,791,792,794,797,799],{"class":344,"line":345},[342,793,663],{"class":374},[342,795,796],{"class":378}," openpyxl ",[342,798,375],{"class":374},[342,800,801],{"class":378}," Workbook, load_workbook\n",[342,803,804,806,809,811],{"class":344,"line":388},[342,805,663],{"class":374},[342,807,808],{"class":378}," openpyxl.styles ",[342,810,375],{"class":374},[342,812,813],{"class":378}," Font\n",[342,815,816],{"class":344,"line":395},[342,817,392],{"emptyLinePlaceholder":391},[342,819,820,823,825],{"class":344,"line":407},[342,821,822],{"class":378},"template ",[342,824,401],{"class":374},[342,826,827],{"class":378}," Workbook()\n",[342,829,830,833,835],{"class":344,"line":433},[342,831,832],{"class":378},"ws ",[342,834,401],{"class":374},[342,836,837],{"class":378}," template.active\n",[342,839,840,843,845],{"class":344,"line":454},[342,841,842],{"class":378},"ws.title ",[342,844,401],{"class":374},[342,846,847],{"class":352}," \"Report\"\n",[342,849,850,853,855,858,860],{"class":344,"line":477},[342,851,852],{"class":378},"ws[",[342,854,591],{"class":352},[342,856,857],{"class":378},"] ",[342,859,401],{"class":374},[342,861,862],{"class":352}," \"Monthly sales report\"\n",[342,864,865,867,869,872,874,877,880,882,884,886,889,891,893],{"class":344,"line":760},[342,866,852],{"class":378},[342,868,591],{"class":352},[342,870,871],{"class":378},"].font ",[342,873,401],{"class":374},[342,875,876],{"class":378}," Font(",[342,878,879],{"class":512},"bold",[342,881,401],{"class":374},[342,883,608],{"class":441},[342,885,419],{"class":378},[342,887,888],{"class":512},"size",[342,890,401],{"class":374},[342,892,618],{"class":441},[342,894,568],{"class":378},[342,896,898,900,902,904,906],{"class":344,"line":897},9,[342,899,852],{"class":378},[342,901,628],{"class":352},[342,903,857],{"class":378},[342,905,401],{"class":374},[342,907,908],{"class":352}," \"Prepared by ops\"\n",[342,910,912,915,918,921,923],{"class":344,"line":911},10,[342,913,914],{"class":378},"ws.column_dimensions[",[342,916,917],{"class":352},"\"B\"",[342,919,920],{"class":378},"].width ",[342,922,401],{"class":374},[342,924,925],{"class":441}," 18\n",[342,927,929,932,935],{"class":344,"line":928},11,[342,930,931],{"class":378},"template.save(",[342,933,934],{"class":352},"\"template.xlsx\"",[342,936,568],{"class":378},[342,938,940],{"class":344,"line":939},12,[342,941,392],{"emptyLinePlaceholder":391},[342,943,945,947,949,951,953,956,958,961,963,965,967,970,972,975,977,980,982,984],{"class":344,"line":944},13,[342,946,501],{"class":374},[342,948,504],{"class":378},[342,950,934],{"class":352},[342,952,419],{"class":378},[342,954,955],{"class":512},"mode",[342,957,401],{"class":374},[342,959,960],{"class":352},"\"a\"",[342,962,419],{"class":378},[342,964,513],{"class":512},[342,966,401],{"class":374},[342,968,969],{"class":352},"\"openpyxl\"",[342,971,419],{"class":378},[342,973,974],{"class":512},"if_sheet_exists",[342,976,401],{"class":374},[342,978,979],{"class":352},"\"overlay\"",[342,981,521],{"class":378},[342,983,382],{"class":374},[342,985,526],{"class":378},[342,987,989,991,993,995,997,999,1001,1003,1005,1007,1009,1011,1013,1015,1017,1019,1021],{"class":344,"line":988},14,[342,990,531],{"class":378},[342,992,534],{"class":512},[342,994,401],{"class":374},[342,996,539],{"class":352},[342,998,419],{"class":378},[342,1000,19],{"class":512},[342,1002,401],{"class":374},[342,1004,203],{"class":441},[342,1006,419],{"class":378},[342,1008,23],{"class":512},[342,1010,401],{"class":374},[342,1012,146],{"class":441},[342,1014,419],{"class":378},[342,1016,560],{"class":512},[342,1018,401],{"class":374},[342,1020,565],{"class":441},[342,1022,568],{"class":378},[342,1024,1026],{"class":344,"line":1025},15,[342,1027,392],{"emptyLinePlaceholder":391},[342,1029,1031,1034,1036,1039,1041,1044,1046],{"class":344,"line":1030},16,[342,1032,1033],{"class":378},"check ",[342,1035,401],{"class":374},[342,1037,1038],{"class":378}," load_workbook(",[342,1040,934],{"class":352},[342,1042,1043],{"class":378},")[",[342,1045,539],{"class":352},[342,1047,583],{"class":378},[342,1049,1051,1053,1056,1058,1061,1063,1066],{"class":344,"line":1050},17,[342,1052,744],{"class":441},[342,1054,1055],{"class":378},"(check[",[342,1057,591],{"class":352},[342,1059,1060],{"class":378},"].value, check[",[342,1062,591],{"class":352},[342,1064,1065],{"class":378},"].font.b)       ",[342,1067,1068],{"class":756},"# Monthly sales report True\n",[342,1070,1072,1074,1076,1078,1080,1083,1086],{"class":344,"line":1071},18,[342,1073,744],{"class":441},[342,1075,1055],{"class":378},[342,1077,750],{"class":352},[342,1079,1060],{"class":378},[342,1081,1082],{"class":352},"\"C6\"",[342,1084,1085],{"class":378},"].value)        ",[342,1087,1088],{"class":756},"# region 410\n",[342,1090,1092,1094,1097,1099,1102],{"class":344,"line":1091},19,[342,1093,744],{"class":441},[342,1095,1096],{"class":378},"(check.column_dimensions[",[342,1098,917],{"class":352},[342,1100,1101],{"class":378},"].width)          ",[342,1103,1104],{"class":756},"# 18.0\n",[10,1106,1107,1108,1110],{},"The title, its font, the note and the column width all survive. That is the whole difference between the ",[13,1109,974],{}," options:",[32,1112,41,1118,41,1121,41,1124,41,1128,41,1134,41,1139,41,1143,41,1149,41,1157,41,1161,41,1168,41,1172,41,1177,41,1181,41,1185,41,1190,41,1193,41,1198,41,1202,41,1206,41,1211,41,1215,41,1219,41,1224,41,1227,41,1232,41,1235,41,1238,41,1242,41,1246,41,1250,41,1256,41,1260,41,1263,41,1268],{"viewBox":1113,"role":35,"ariaLabelledBy":1114,"xmlns":39,"style":1117},"4 0 752 181",[1115,1116],"cell-modes-t","cell-modes-d","width:100%;max-width:752px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif",[43,1119,1120],{"id":1115},"What each if_sheet_exists option does to an existing sheet",[47,1122,1123],{"id":1116},"error refuses to write if the sheet exists. new creates a second sheet with a numbered name. replace deletes the sheet and writes into a fresh empty one, losing formatting. overlay writes into the existing sheet, changing only the cells the DataFrame covers.",[51,1125],{"x":203,"y":54,"width":1126,"height":1127,"fill":57},"752","181",[51,1129],{"x":1130,"y":61,"width":1131,"height":1132,"rx":618,"fill":65,"stroke":66,"style":1133},"20.0","166.5","149.0","stroke-width:2px",[85,1135,1138],{"x":1136,"y":99,"style":1137},"103.2","font-size:14px;font-weight:700;fill:var(--text,#172033);text-anchor:middle","\"error\" (default)",[344,1140],{"x1":88,"y1":1141,"x2":1142,"y2":1141,"stroke":66,"style":96},"57.0","170.5",[85,1144,1148],{"x":1145,"y":1146,"style":1147},"60.0","77.0","font-size:12px;font-weight:400;fill:var(--text,#172033);text-anchor:start","raises ValueError",[74,1150,1152],{"transform":1151},"translate(38.5,65.5) scale(0.625)",[78,1153],{"d":1154,"fill":81,"stroke":1155,"style":1156},"M6 6l12 12 M18 6L6 18","var(--accent,#f43f8f)","stroke-width:2.88px;stroke-linecap:round;stroke-linejoin:round",[85,1158,1160],{"x":1145,"y":1159,"style":1147},"103.0","nothing written",[74,1162,1164],{"transform":1163},"translate(38.5,91.5) scale(0.625)",[78,1165],{"d":1166,"fill":81,"stroke":1167,"style":1156},"M12 3.5l9.5 17h-19z M12 10v5 M12 17.8v.4","var(--gold,#b4740a)",[51,1169],{"x":1170,"y":61,"width":1131,"height":1132,"rx":618,"fill":1171,"stroke":1167,"style":1133},"204.5","#fdefd8",[85,1173,1176],{"x":1174,"y":99,"style":1175},"287.8","font-size:14px;font-weight:700;fill:var(--gold-ink,#7a4e06);text-anchor:middle","\"new\"",[344,1178],{"x1":1179,"y1":1141,"x2":1180,"y2":1141,"stroke":1167,"style":96},"220.5","355.0",[85,1182,1184],{"x":1183,"y":1146,"style":1147},"244.5","writes to Report1",[74,1186,1188],{"transform":1187},"translate(223.0,65.5) scale(0.625)",[78,1189],{"d":1166,"fill":81,"stroke":1167,"style":1156},[85,1191,1192],{"x":1183,"y":1159,"style":1147},"template left",[74,1194,1196],{"transform":1195},"translate(223.0,91.5) scale(0.625)",[78,1197],{"d":1166,"fill":81,"stroke":1167,"style":1156},[85,1199,1201],{"x":1183,"y":1200,"style":1147},"120.0","untouched",[51,1203],{"x":1204,"y":61,"width":1131,"height":1132,"rx":618,"fill":1205,"stroke":1155,"style":1133},"389.0","#fee8f2",[85,1207,1210],{"x":1208,"y":99,"style":1209},"472.2","font-size:14px;font-weight:700;fill:var(--accent-ink,#be185d);text-anchor:middle","\"replace\"",[344,1212],{"x1":1213,"y1":1141,"x2":1214,"y2":1141,"stroke":1155,"style":96},"405.0","539.5",[85,1216,1218],{"x":1217,"y":1146,"style":1147},"429.0","sheet deleted first",[74,1220,1222],{"transform":1221},"translate(407.5,65.5) scale(0.625)",[78,1223],{"d":1154,"fill":81,"stroke":1155,"style":1156},[85,1225,1226],{"x":1217,"y":1159,"style":1147},"title, widths, notes",[74,1228,1230],{"transform":1229},"translate(407.5,91.5) scale(0.625)",[78,1231],{"d":1154,"fill":81,"stroke":1155,"style":1156},[85,1233,1234],{"x":1217,"y":1200,"style":1147},"lost",[51,1236],{"x":1237,"y":61,"width":1131,"height":1132,"rx":618,"fill":225,"stroke":226,"style":1133},"573.5",[85,1239,979],{"x":1240,"y":99,"style":1241},"656.8","font-size:14px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle",[344,1243],{"x1":1244,"y1":1141,"x2":1245,"y2":1141,"stroke":226,"style":96},"589.5","724.0",[85,1247,1249],{"x":1248,"y":1146,"style":1147},"613.5","writes into the",[74,1251,1253],{"transform":1252},"translate(592.0,65.5) scale(0.625)",[78,1254],{"d":1255,"fill":81,"stroke":226,"style":1156},"M5 12.5l4.5 4.5L19 7",[85,1257,1259],{"x":1248,"y":1258,"style":1147},"94.0","sheet",[85,1261,1262],{"x":1248,"y":1200,"style":1147},"only covered cells",[74,1264,1266],{"transform":1265},"translate(592.0,108.5) scale(0.625)",[78,1267],{"d":1255,"fill":81,"stroke":226,"style":1156},[85,1269,1271],{"x":1248,"y":1270,"style":1147},"137.0","change",[10,1273,1274,1277],{},[13,1275,1276],{},"overlay"," also means stale values remain. If last month's table had five rows and this month's has three, rows four and five from last month are still there underneath. Clear the data area before writing, as in Step 4.",[328,1279,1281],{"id":1280},"step-3-fill-a-designed-header-with-values-only","Step 3 — Fill a designed header with values only",[10,1283,1284,1285,1288],{},"Templates often have the header row already styled — merged, coloured, maybe with line breaks in the labels. Write just the values under it with ",[13,1286,1287],{},"header=False",", starting one row lower:",[333,1290,1292],{"className":365,"code":1291,"language":367,"meta":338,"style":338},"with pd.ExcelWriter(\"template.xlsx\", mode=\"a\", engine=\"openpyxl\", if_sheet_exists=\"overlay\") as writer:\n    sales.to_excel(writer, sheet_name=\"Report\", startrow=5, startcol=1, index=False, header=False)\n",[13,1293,1294,1332],{"__ignoreMap":338},[342,1295,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330],{"class":344,"line":345},[342,1297,501],{"class":374},[342,1299,504],{"class":378},[342,1301,934],{"class":352},[342,1303,419],{"class":378},[342,1305,955],{"class":512},[342,1307,401],{"class":374},[342,1309,960],{"class":352},[342,1311,419],{"class":378},[342,1313,513],{"class":512},[342,1315,401],{"class":374},[342,1317,969],{"class":352},[342,1319,419],{"class":378},[342,1321,974],{"class":512},[342,1323,401],{"class":374},[342,1325,979],{"class":352},[342,1327,521],{"class":378},[342,1329,382],{"class":374},[342,1331,526],{"class":378},[342,1333,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1371,1373,1375],{"class":344,"line":388},[342,1335,531],{"class":378},[342,1337,534],{"class":512},[342,1339,401],{"class":374},[342,1341,539],{"class":352},[342,1343,419],{"class":378},[342,1345,19],{"class":512},[342,1347,401],{"class":374},[342,1349,220],{"class":441},[342,1351,419],{"class":378},[342,1353,23],{"class":512},[342,1355,401],{"class":374},[342,1357,146],{"class":441},[342,1359,419],{"class":378},[342,1361,560],{"class":512},[342,1363,401],{"class":374},[342,1365,565],{"class":441},[342,1367,419],{"class":378},[342,1369,1370],{"class":512},"header",[342,1372,401],{"class":374},[342,1374,565],{"class":441},[342,1376,568],{"class":378},[10,1378,1379,1380,30],{},"The designed header in row 5 is untouched and the values land from B6. This is the core move of template-driven reporting; the full workflow, including keeping charts and images alive, is in ",[26,1381,1383],{"href":1382},"\u002Fautomating-reporting-workflows\u002Fgenerating-excel-reports-from-templates\u002Fpopulate-excel-template-without-losing-formatting\u002F","Populate an Excel Template Without Losing Formatting",[328,1385,1387],{"id":1386},"step-4-clear-the-old-data-area-first","Step 4 — Clear the old data area first",[10,1389,1390],{},"Because overlay only writes where the new frame has cells, clear the whole data region before every run. openpyxl can blank a block while keeping cell formatting:",[333,1392,1394],{"className":365,"code":1393,"language":367,"meta":338,"style":338},"def clear_block(path: str, sheet: str, first_row: int, first_col: int, n_cols: int) -> None:\n    wb = load_workbook(path)\n    ws = wb[sheet]\n    for row in ws.iter_rows(min_row=first_row, max_row=ws.max_row,\n                            min_col=first_col, max_col=first_col + n_cols - 1):\n        for cell in row:\n            cell.value = None\n    wb.save(path)\n\nclear_block(\"template.xlsx\", \"Report\", first_row=6, first_col=2, n_cols=3)   # B6 downwards\nwith pd.ExcelWriter(\"template.xlsx\", mode=\"a\", engine=\"openpyxl\", if_sheet_exists=\"overlay\") as writer:\n    sales.head(2).to_excel(writer, sheet_name=\"Report\", startrow=5, startcol=1, index=False, header=False)\n\nreport = load_workbook(\"template.xlsx\")[\"Report\"]\nprint([report.cell(row=r, column=2).value for r in range(6, 10)])  # ['North', 'South', None, None]\n",[13,1395,1396,1437,1447,1457,1486,1517,1530,1540,1545,1549,1593,1631,1681,1685,1702],{"__ignoreMap":338},[342,1397,1398,1400,1403,1406,1408,1411,1413,1416,1418,1421,1423,1426,1428,1431,1434],{"class":344,"line":345},[342,1399,680],{"class":374},[342,1401,1402],{"class":683}," clear_block",[342,1404,1405],{"class":378},"(path: ",[342,1407,690],{"class":441},[342,1409,1410],{"class":378},", sheet: ",[342,1412,690],{"class":441},[342,1414,1415],{"class":378},", first_row: ",[342,1417,696],{"class":441},[342,1419,1420],{"class":378},", first_col: ",[342,1422,696],{"class":441},[342,1424,1425],{"class":378},", n_cols: ",[342,1427,696],{"class":441},[342,1429,1430],{"class":378},") -> ",[342,1432,1433],{"class":441},"None",[342,1435,1436],{"class":378},":\n",[342,1438,1439,1442,1444],{"class":344,"line":388},[342,1440,1441],{"class":378},"    wb ",[342,1443,401],{"class":374},[342,1445,1446],{"class":378}," load_workbook(path)\n",[342,1448,1449,1452,1454],{"class":344,"line":395},[342,1450,1451],{"class":378},"    ws ",[342,1453,401],{"class":374},[342,1455,1456],{"class":378}," wb[sheet]\n",[342,1458,1459,1462,1464,1467,1470,1473,1475,1478,1481,1483],{"class":344,"line":407},[342,1460,1461],{"class":374},"    for",[342,1463,721],{"class":378},[342,1465,1466],{"class":374},"in",[342,1468,1469],{"class":378}," ws.iter_rows(",[342,1471,1472],{"class":512},"min_row",[342,1474,401],{"class":374},[342,1476,1477],{"class":378},"first_row, ",[342,1479,1480],{"class":512},"max_row",[342,1482,401],{"class":374},[342,1484,1485],{"class":378},"ws.max_row,\n",[342,1487,1488,1491,1493,1496,1499,1501,1504,1507,1510,1512,1514],{"class":344,"line":433},[342,1489,1490],{"class":512},"                            min_col",[342,1492,401],{"class":374},[342,1494,1495],{"class":378},"first_col, ",[342,1497,1498],{"class":512},"max_col",[342,1500,401],{"class":374},[342,1502,1503],{"class":378},"first_col ",[342,1505,1506],{"class":374},"+",[342,1508,1509],{"class":378}," n_cols ",[342,1511,724],{"class":374},[342,1513,727],{"class":441},[342,1515,1516],{"class":378},"):\n",[342,1518,1519,1522,1525,1527],{"class":344,"line":454},[342,1520,1521],{"class":374},"        for",[342,1523,1524],{"class":378}," cell ",[342,1526,1466],{"class":374},[342,1528,1529],{"class":378}," row:\n",[342,1531,1532,1535,1537],{"class":344,"line":477},[342,1533,1534],{"class":378},"            cell.value ",[342,1536,401],{"class":374},[342,1538,1539],{"class":441}," None\n",[342,1541,1542],{"class":344,"line":760},[342,1543,1544],{"class":378},"    wb.save(path)\n",[342,1546,1547],{"class":344,"line":897},[342,1548,392],{"emptyLinePlaceholder":391},[342,1550,1551,1554,1556,1558,1560,1562,1565,1567,1569,1571,1574,1576,1578,1580,1583,1585,1587,1590],{"class":344,"line":911},[342,1552,1553],{"class":378},"clear_block(",[342,1555,934],{"class":352},[342,1557,419],{"class":378},[342,1559,539],{"class":352},[342,1561,419],{"class":378},[342,1563,1564],{"class":512},"first_row",[342,1566,401],{"class":374},[342,1568,249],{"class":441},[342,1570,419],{"class":378},[342,1572,1573],{"class":512},"first_col",[342,1575,401],{"class":374},[342,1577,165],{"class":441},[342,1579,419],{"class":378},[342,1581,1582],{"class":512},"n_cols",[342,1584,401],{"class":374},[342,1586,186],{"class":441},[342,1588,1589],{"class":378},")   ",[342,1591,1592],{"class":756},"# B6 downwards\n",[342,1594,1595,1597,1599,1601,1603,1605,1607,1609,1611,1613,1615,1617,1619,1621,1623,1625,1627,1629],{"class":344,"line":928},[342,1596,501],{"class":374},[342,1598,504],{"class":378},[342,1600,934],{"class":352},[342,1602,419],{"class":378},[342,1604,955],{"class":512},[342,1606,401],{"class":374},[342,1608,960],{"class":352},[342,1610,419],{"class":378},[342,1612,513],{"class":512},[342,1614,401],{"class":374},[342,1616,969],{"class":352},[342,1618,419],{"class":378},[342,1620,974],{"class":512},[342,1622,401],{"class":374},[342,1624,979],{"class":352},[342,1626,521],{"class":378},[342,1628,382],{"class":374},[342,1630,526],{"class":378},[342,1632,1633,1636,1638,1641,1643,1645,1647,1649,1651,1653,1655,1657,1659,1661,1663,1665,1667,1669,1671,1673,1675,1677,1679],{"class":344,"line":939},[342,1634,1635],{"class":378},"    sales.head(",[342,1637,165],{"class":441},[342,1639,1640],{"class":378},").to_excel(writer, ",[342,1642,534],{"class":512},[342,1644,401],{"class":374},[342,1646,539],{"class":352},[342,1648,419],{"class":378},[342,1650,19],{"class":512},[342,1652,401],{"class":374},[342,1654,220],{"class":441},[342,1656,419],{"class":378},[342,1658,23],{"class":512},[342,1660,401],{"class":374},[342,1662,146],{"class":441},[342,1664,419],{"class":378},[342,1666,560],{"class":512},[342,1668,401],{"class":374},[342,1670,565],{"class":441},[342,1672,419],{"class":378},[342,1674,1370],{"class":512},[342,1676,401],{"class":374},[342,1678,565],{"class":441},[342,1680,568],{"class":378},[342,1682,1683],{"class":344,"line":944},[342,1684,392],{"emptyLinePlaceholder":391},[342,1686,1687,1690,1692,1694,1696,1698,1700],{"class":344,"line":988},[342,1688,1689],{"class":378},"report ",[342,1691,401],{"class":374},[342,1693,1038],{"class":378},[342,1695,934],{"class":352},[342,1697,1043],{"class":378},[342,1699,539],{"class":352},[342,1701,583],{"class":378},[342,1703,1704,1706,1709,1712,1714,1717,1720,1722,1724,1727,1730,1733,1735,1738,1741,1743,1745,1748,1751],{"class":344,"line":1025},[342,1705,744],{"class":441},[342,1707,1708],{"class":378},"([report.cell(",[342,1710,1711],{"class":512},"row",[342,1713,401],{"class":374},[342,1715,1716],{"class":378},"r, ",[342,1718,1719],{"class":512},"column",[342,1721,401],{"class":374},[342,1723,165],{"class":441},[342,1725,1726],{"class":378},").value ",[342,1728,1729],{"class":374},"for",[342,1731,1732],{"class":378}," r ",[342,1734,1466],{"class":374},[342,1736,1737],{"class":441}," range",[342,1739,1740],{"class":378},"(",[342,1742,249],{"class":441},[342,1744,419],{"class":378},[342,1746,1747],{"class":441},"10",[342,1749,1750],{"class":378},")])  ",[342,1752,1753],{"class":756},"# ['North', 'South', None, None]\n",[10,1755,1756,1757,1760],{},"Setting ",[13,1758,1759],{},"cell.value = None"," keeps the cell's number format, fill and borders, so the designed banding of the data area stays in place for the next run.",[328,1762,1764],{"id":1763},"step-5-stack-several-tables-on-one-sheet","Step 5 — Stack several tables on one sheet",[10,1766,1767],{},"Offsets also let you place several frames on one sheet, one under another. Track the next free row as you go, leaving a gap and a caption between tables:",[333,1769,1771],{"className":365,"code":1770,"language":367,"meta":338,"style":338},"by_region = sales.set_index(\"region\")\ntop = sales.nlargest(2, \"revenue\")\n\nwith pd.ExcelWriter(\"stacked.xlsx\", engine=\"xlsxwriter\") as writer:\n    row = 0\n    for caption, frame in [(\"By region\", by_region), (\"Top two\", top)]:\n        frame.to_excel(writer, sheet_name=\"Summary\", startrow=row + 1)\n        writer.sheets[\"Summary\"].write(row, 0, caption)\n        row += len(frame) + 4          # caption + header + rows + gap\n",[13,1772,1773,1788,1807,1811,1834,1844,1868,1895,1910],{"__ignoreMap":338},[342,1774,1775,1778,1780,1783,1786],{"class":344,"line":345},[342,1776,1777],{"class":378},"by_region ",[342,1779,401],{"class":374},[342,1781,1782],{"class":378}," sales.set_index(",[342,1784,1785],{"class":352},"\"region\"",[342,1787,568],{"class":378},[342,1789,1790,1793,1795,1798,1800,1802,1805],{"class":344,"line":388},[342,1791,1792],{"class":378},"top ",[342,1794,401],{"class":374},[342,1796,1797],{"class":378}," sales.nlargest(",[342,1799,165],{"class":441},[342,1801,419],{"class":378},[342,1803,1804],{"class":352},"\"revenue\"",[342,1806,568],{"class":378},[342,1808,1809],{"class":344,"line":395},[342,1810,392],{"emptyLinePlaceholder":391},[342,1812,1813,1815,1817,1820,1822,1824,1826,1828,1830,1832],{"class":344,"line":407},[342,1814,501],{"class":374},[342,1816,504],{"class":378},[342,1818,1819],{"class":352},"\"stacked.xlsx\"",[342,1821,419],{"class":378},[342,1823,513],{"class":512},[342,1825,401],{"class":374},[342,1827,518],{"class":352},[342,1829,521],{"class":378},[342,1831,382],{"class":374},[342,1833,526],{"class":378},[342,1835,1836,1839,1841],{"class":344,"line":433},[342,1837,1838],{"class":378},"    row ",[342,1840,401],{"class":374},[342,1842,1843],{"class":441}," 0\n",[342,1845,1846,1848,1851,1853,1856,1859,1862,1865],{"class":344,"line":454},[342,1847,1461],{"class":374},[342,1849,1850],{"class":378}," caption, frame ",[342,1852,1466],{"class":374},[342,1854,1855],{"class":378}," [(",[342,1857,1858],{"class":352},"\"By region\"",[342,1860,1861],{"class":378},", by_region), (",[342,1863,1864],{"class":352},"\"Top two\"",[342,1866,1867],{"class":378},", top)]:\n",[342,1869,1870,1873,1875,1877,1880,1882,1884,1886,1889,1891,1893],{"class":344,"line":477},[342,1871,1872],{"class":378},"        frame.to_excel(writer, ",[342,1874,534],{"class":512},[342,1876,401],{"class":374},[342,1878,1879],{"class":352},"\"Summary\"",[342,1881,419],{"class":378},[342,1883,19],{"class":512},[342,1885,401],{"class":374},[342,1887,1888],{"class":378},"row ",[342,1890,1506],{"class":374},[342,1892,727],{"class":441},[342,1894,568],{"class":378},[342,1896,1897,1900,1902,1905,1907],{"class":344,"line":760},[342,1898,1899],{"class":378},"        writer.sheets[",[342,1901,1879],{"class":352},[342,1903,1904],{"class":378},"].write(row, ",[342,1906,54],{"class":441},[342,1908,1909],{"class":378},", caption)\n",[342,1911,1912,1915,1918,1921,1924,1926,1929],{"class":344,"line":897},[342,1913,1914],{"class":378},"        row ",[342,1916,1917],{"class":374},"+=",[342,1919,1920],{"class":441}," len",[342,1922,1923],{"class":378},"(frame) ",[342,1925,1506],{"class":374},[342,1927,1928],{"class":441}," 4",[342,1930,1931],{"class":756},"          # caption + header + rows + gap\n",[10,1933,1934,1937,1938,1942,1943,1945,1946,30],{},[13,1935,1936],{},"len(frame)"," counts data rows only, so add one for the header and one for the caption line; a MultiIndex header takes more rows, as ",[26,1939,1941],{"href":1940},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-multiindex-dataframe-to-excel\u002F","Write a MultiIndex DataFrame to Excel with pandas"," explains. Side-by-side layouts work the same way with ",[13,1944,23],{}," — the pattern is covered in ",[26,1947,1949],{"href":1948},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fwrite-multiple-dataframes-to-one-excel-file\u002F","Write Multiple DataFrames to One Excel File",[32,1951,41,1957,41,1960,41,1963,41,1968,41,1973,41,1978,41,1983,41,1987,41,1992,41,1998,41,2001,41,2006],{"viewBox":1952,"role":35,"ariaLabelledBy":1953,"xmlns":39,"style":1956},"104 0 552 186",[1954,1955],"cell-stack-t","cell-stack-d","width:100%;max-width:552px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif",[43,1958,1959],{"id":1954},"Two tables stacked on one sheet with a running row counter",[47,1961,1962],{"id":1955},"The first table starts at row 0 with its caption, its header and rows follow, then a gap. The row counter advances by the table length plus caption, header and gap rows, and the second table starts there.",[51,1964],{"x":1965,"y":54,"width":1966,"height":1967,"fill":57},"104","552","186",[51,1969],{"x":1200,"y":61,"width":1970,"height":1971,"rx":1972,"fill":150,"stroke":151,"style":1133},"520.0","59.0","12",[85,1974,1977],{"x":323,"y":1975,"style":1976},"41.5","font-size:13.5px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","row 0: caption, row 1: header",[85,1979,1982],{"x":323,"y":1980,"style":1981},"61.0","font-size:11.5px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","first table starts at startrow=1",[344,1984],{"x1":323,"y1":1985,"x2":323,"y2":1986,"stroke":151,"style":1133},"80.0","102.0",[1988,1989],"polygon",{"points":1990,"fill":1991},"380.0,106.0 375.0,97.0 385.0,97.0","#5b5cf0",[85,1993,1997],{"x":1994,"y":1995,"style":1996},"392.0","97.0","font-size:11px;font-weight:700;fill:var(--muted,#5b6780);text-anchor:start","row += len(frame) + 4",[51,1999],{"x":1200,"y":2000,"width":1970,"height":1971,"rx":1972,"fill":225,"stroke":226,"style":1133},"111.0",[85,2002,2005],{"x":323,"y":2003,"style":2004},"136.5","font-size:13.5px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","row 7: caption, row 8: header",[85,2007,2009],{"x":323,"y":2008,"style":1981},"156.0","second table starts at startrow=8",[328,2011,2013],{"id":2012},"step-6-anchor-the-table-to-a-named-cell-not-a-hard-coded-address","Step 6 — Anchor the table to a named cell, not a hard-coded address",[10,2015,2016,2017,2020,2021,2025,2026,2029],{},"Hard-coding ",[13,2018,2019],{},"startrow=5, startcol=1"," couples your script to the template's layout. The day someone adds a row to the title block, every run writes one row too high, over the header. A sturdier contract is a ",[2022,2023,2024],"em",{},"defined name"," in the template: whoever designs the sheet marks the top-left data cell as ",[13,2027,2028],{},"data_start",", and the script looks it up.",[333,2031,2033],{"className":365,"code":2032,"language":367,"meta":338,"style":338},"from openpyxl.workbook.defined_name import DefinedName\n\nwb = load_workbook(\"template.xlsx\")\nwb.defined_names[\"data_start\"] = DefinedName(\"data_start\", attr_text=\"Report!$B$6\")\nwb.save(\"template.xlsx\")\n\ndef anchor(path: str, name: str) -> tuple[str, int, int]:\n    book = load_workbook(path)\n    sheet_name, ref = next(iter(book.defined_names[name].destinations))\n    return sheet_name, *offsets(ref.replace(\"$\", \"\"))\n\nsheet_name, start_row, start_col = anchor(\"template.xlsx\", \"data_start\")\nprint(sheet_name, start_row, start_col)     # Report 5 1\n\nwith pd.ExcelWriter(\"template.xlsx\", mode=\"a\", engine=\"openpyxl\", if_sheet_exists=\"overlay\") as writer:\n    sales.to_excel(writer, sheet_name=sheet_name, startrow=start_row, startcol=start_col,\n                   index=False, header=False)\n",[13,2034,2035,2047,2051,2064,2093,2102,2106,2136,2145,2163,2187,2191,2209,2219,2223,2261,2286],{"__ignoreMap":338},[342,2036,2037,2039,2042,2044],{"class":344,"line":345},[342,2038,663],{"class":374},[342,2040,2041],{"class":378}," openpyxl.workbook.defined_name ",[342,2043,375],{"class":374},[342,2045,2046],{"class":378}," DefinedName\n",[342,2048,2049],{"class":344,"line":388},[342,2050,392],{"emptyLinePlaceholder":391},[342,2052,2053,2056,2058,2060,2062],{"class":344,"line":395},[342,2054,2055],{"class":378},"wb ",[342,2057,401],{"class":374},[342,2059,1038],{"class":378},[342,2061,934],{"class":352},[342,2063,568],{"class":378},[342,2065,2066,2069,2072,2074,2076,2079,2081,2083,2086,2088,2091],{"class":344,"line":407},[342,2067,2068],{"class":378},"wb.defined_names[",[342,2070,2071],{"class":352},"\"data_start\"",[342,2073,857],{"class":378},[342,2075,401],{"class":374},[342,2077,2078],{"class":378}," DefinedName(",[342,2080,2071],{"class":352},[342,2082,419],{"class":378},[342,2084,2085],{"class":512},"attr_text",[342,2087,401],{"class":374},[342,2089,2090],{"class":352},"\"Report!$B$6\"",[342,2092,568],{"class":378},[342,2094,2095,2098,2100],{"class":344,"line":433},[342,2096,2097],{"class":378},"wb.save(",[342,2099,934],{"class":352},[342,2101,568],{"class":378},[342,2103,2104],{"class":344,"line":454},[342,2105,392],{"emptyLinePlaceholder":391},[342,2107,2108,2110,2113,2115,2117,2120,2122,2124,2126,2128,2130,2132,2134],{"class":344,"line":477},[342,2109,680],{"class":374},[342,2111,2112],{"class":683}," anchor",[342,2114,1405],{"class":378},[342,2116,690],{"class":441},[342,2118,2119],{"class":378},", name: ",[342,2121,690],{"class":441},[342,2123,693],{"class":378},[342,2125,690],{"class":441},[342,2127,419],{"class":378},[342,2129,696],{"class":441},[342,2131,419],{"class":378},[342,2133,696],{"class":441},[342,2135,703],{"class":378},[342,2137,2138,2141,2143],{"class":344,"line":760},[342,2139,2140],{"class":378},"    book ",[342,2142,401],{"class":374},[342,2144,1446],{"class":378},[342,2146,2147,2150,2152,2155,2157,2160],{"class":344,"line":897},[342,2148,2149],{"class":378},"    sheet_name, ref ",[342,2151,401],{"class":374},[342,2153,2154],{"class":441}," next",[342,2156,1740],{"class":378},[342,2158,2159],{"class":441},"iter",[342,2161,2162],{"class":378},"(book.defined_names[name].destinations))\n",[342,2164,2165,2167,2170,2173,2176,2179,2181,2184],{"class":344,"line":911},[342,2166,718],{"class":374},[342,2168,2169],{"class":378}," sheet_name, ",[342,2171,2172],{"class":374},"*",[342,2174,2175],{"class":378},"offsets(ref.replace(",[342,2177,2178],{"class":352},"\"$\"",[342,2180,419],{"class":378},[342,2182,2183],{"class":352},"\"\"",[342,2185,2186],{"class":378},"))\n",[342,2188,2189],{"class":344,"line":928},[342,2190,392],{"emptyLinePlaceholder":391},[342,2192,2193,2196,2198,2201,2203,2205,2207],{"class":344,"line":939},[342,2194,2195],{"class":378},"sheet_name, start_row, start_col ",[342,2197,401],{"class":374},[342,2199,2200],{"class":378}," anchor(",[342,2202,934],{"class":352},[342,2204,419],{"class":378},[342,2206,2071],{"class":352},[342,2208,568],{"class":378},[342,2210,2211,2213,2216],{"class":344,"line":944},[342,2212,744],{"class":441},[342,2214,2215],{"class":378},"(sheet_name, start_row, start_col)     ",[342,2217,2218],{"class":756},"# Report 5 1\n",[342,2220,2221],{"class":344,"line":988},[342,2222,392],{"emptyLinePlaceholder":391},[342,2224,2225,2227,2229,2231,2233,2235,2237,2239,2241,2243,2245,2247,2249,2251,2253,2255,2257,2259],{"class":344,"line":1025},[342,2226,501],{"class":374},[342,2228,504],{"class":378},[342,2230,934],{"class":352},[342,2232,419],{"class":378},[342,2234,955],{"class":512},[342,2236,401],{"class":374},[342,2238,960],{"class":352},[342,2240,419],{"class":378},[342,2242,513],{"class":512},[342,2244,401],{"class":374},[342,2246,969],{"class":352},[342,2248,419],{"class":378},[342,2250,974],{"class":512},[342,2252,401],{"class":374},[342,2254,979],{"class":352},[342,2256,521],{"class":378},[342,2258,382],{"class":374},[342,2260,526],{"class":378},[342,2262,2263,2265,2267,2269,2272,2274,2276,2279,2281,2283],{"class":344,"line":1030},[342,2264,531],{"class":378},[342,2266,534],{"class":512},[342,2268,401],{"class":374},[342,2270,2271],{"class":378},"sheet_name, ",[342,2273,19],{"class":512},[342,2275,401],{"class":374},[342,2277,2278],{"class":378},"start_row, ",[342,2280,23],{"class":512},[342,2282,401],{"class":374},[342,2284,2285],{"class":378},"start_col,\n",[342,2287,2288,2291,2293,2295,2297,2299,2301,2303],{"class":344,"line":1050},[342,2289,2290],{"class":512},"                   index",[342,2292,401],{"class":374},[342,2294,565],{"class":441},[342,2296,419],{"class":378},[342,2298,1370],{"class":512},[342,2300,401],{"class":374},[342,2302,565],{"class":441},[342,2304,568],{"class":378},[10,2306,2307,2308,30],{},"When the template designer inserts rows above the table in Excel, Excel moves the defined name with the cell, so the script keeps writing to the right place without a code change. It also documents intent: a reader of the template can open Name Manager and see exactly where automation writes. Named ranges are covered in more depth in ",[26,2309,2311],{"href":2310},"\u002Fgetting-started-with-python-excel-automation\u002Fworking-with-excel-formulas-in-python\u002Fcreate-named-range-in-excel-with-openpyxl\u002F","Create a Named Range in Excel with openpyxl",[328,2313,2315],{"id":2314},"common-pitfalls","Common pitfalls",[2317,2318,2319,2335,2344,2361],"ul",{},[2320,2321,2322,2326,2327,2330,2331,2334],"li",{},[2323,2324,2325],"strong",{},"One-based offsets."," ",[13,2328,2329],{},"startrow=5"," puts the header in row 6. Use the ",[13,2332,2333],{},"offsets()"," helper instead of converting in your head.",[2320,2336,2337,2343],{},[2323,2338,2339,2342],{},[13,2340,2341],{},"mode=\"a\""," with xlsxwriter."," xlsxwriter only creates new files, so append mode requires the openpyxl engine; pandas raises if you combine them.",[2320,2345,2346,2349,2350,2353,2354,2356,2357,2360],{},[2323,2347,2348],{},"The index column shifts everything."," With the default ",[13,2351,2352],{},"index=True",", the first DataFrame column lands one column right of ",[13,2355,23],{},". Pass ",[13,2358,2359],{},"index=False"," or allow for it.",[2320,2362,2363,2366],{},[2323,2364,2365],{},"Overlay leaves stale rows."," Clear the data area first when the row count can shrink between runs.",[328,2368,2370],{"id":2369},"performance-and-scale-notes","Performance and scale notes",[10,2372,2373],{},"Append mode loads the whole existing workbook with openpyxl, edits it in memory and saves it again. For a template of a few sheets that takes a fraction of a second; for a workbook with hundreds of thousands of existing cells it can take many seconds and a lot of memory, and saving through openpyxl can drop features it does not support. When the template is large, keep the template itself small — layout and formatting only — and put bulk data on a separate sheet written in one pass with xlsxwriter.",[328,2375,2377],{"id":2376},"conclusion","Conclusion",[10,2379,2380,20,2382,2384,2385,2387,2388,2390,2391,2393],{},[13,2381,19],{},[13,2383,23],{}," place a DataFrame anywhere, counting from zero at A1. For a new file, write through an ",[13,2386,641],{}," and decorate the sheet with the engine's API in the same pass. For an existing template, use ",[13,2389,2341],{},", the openpyxl engine and ",[13,2392,783],{},", write values only under a designed header, and clear the data area first so shrinking tables do not leave stale rows behind.",[328,2395,2397],{"id":2396},"frequently-asked-questions","Frequently asked questions",[10,2399,2400,2403],{},[2323,2401,2402],{},"Are startrow and startcol zero-based?","\nYes. startrow=0 and startcol=0 is cell A1, so to put the header in cell B5 you pass startrow=4 and startcol=1.",[10,2405,2406,2409],{},[2323,2407,2408],{},"How do I write into an existing sheet without deleting what is already there?","\nOpen the file with pd.ExcelWriter in mode=\"a\" with the openpyxl engine and if_sheet_exists=\"overlay\". pandas then writes only the cells covered by the DataFrame and leaves the rest of the sheet, including formatting, as it was.",[10,2411,2412,2415],{},[2323,2413,2414],{},"What is the difference between overlay and replace?","\nreplace deletes the existing sheet and creates a fresh empty one with the same name before writing, so titles, notes and column widths are lost. overlay writes into the existing sheet.",[10,2417,2418,2421],{},[2323,2419,2420],{},"Can I write only the values, without the header?","\nYes. Pass header=False, and index=False if you do not want the index either. This is how you fill the data area of a template whose header row is already designed.",[328,2423,2425],{"id":2424},"related","Related",[2317,2427,2428,2434,2441,2448],{},[2320,2429,2430,2431,2433],{},"Up one level: ",[26,2432,29],{"href":28}," — the writer options in context.",[2320,2435,2436,2440],{},[26,2437,2439],{"href":2438},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fappend-a-dataframe-to-an-existing-excel-file-with-pandas\u002F","Append a DataFrame to an Existing Excel File with pandas"," — adding rows below existing data.",[2320,2442,2443,2447],{},[26,2444,2446],{"href":2445},"\u002Fautomating-reporting-workflows\u002Fgenerating-excel-reports-from-templates\u002Ffill-excel-template-with-python-openpyxl\u002F","Fill an Excel Template with Python and openpyxl"," — cell-by-cell template filling.",[2320,2449,2450,2454],{},[26,2451,2453],{"href":2452},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-pandas-dataframe-to-excel-without-index\u002F","Write a Pandas DataFrame to Excel Without the Index"," — keep the index out of the offset maths.",[2456,2457,2458],"style",{},"html pre.shiki code .sMTad, html code.shiki .sMTad{--shiki-default:#6F42C1;--shiki-dark:#FFB757}html pre.shiki code .srMev, html code.shiki .srMev{--shiki-default:#032F62;--shiki-dark:#ADDCFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s-kum, html code.shiki .s-kum{--shiki-default:#D73A49;--shiki-dark:#FF9492}html pre.shiki code .skGVy, html code.shiki .skGVy{--shiki-default:#24292E;--shiki-dark:#F0F3F6}html pre.shiki code .sP0c6, html code.shiki .sP0c6{--shiki-default:#005CC5;--shiki-dark:#91CBFF}html pre.shiki code .sa561, html code.shiki .sa561{--shiki-default:#E36209;--shiki-dark:#FFB757}html pre.shiki code .s_Opv, html code.shiki .s_Opv{--shiki-default:#6F42C1;--shiki-dark:#DBB7FF}html pre.shiki code .s-wDw, html code.shiki .s-wDw{--shiki-default:#6A737D;--shiki-dark:#BDC4CC}",{"title":338,"searchDepth":388,"depth":388,"links":2460},[2461,2462,2463,2464,2465,2466,2467,2468,2469,2470,2471,2472],{"id":330,"depth":388,"text":331},{"id":483,"depth":388,"text":484},{"id":776,"depth":388,"text":777},{"id":1280,"depth":388,"text":1281},{"id":1386,"depth":388,"text":1387},{"id":1763,"depth":388,"text":1764},{"id":2012,"depth":388,"text":2013},{"id":2314,"depth":388,"text":2315},{"id":2369,"depth":388,"text":2370},{"id":2376,"depth":388,"text":2377},{"id":2396,"depth":388,"text":2397},{"id":2424,"depth":388,"text":2425},"2026-09-23","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.","md",[2477,2479,2481,2483],{"q":2402,"a":2478},"Yes. startrow=0 and startcol=0 is cell A1, so to put the header in cell B5 you pass startrow=4 and startcol=1.",{"q":2408,"a":2480},"Open the file with pd.ExcelWriter in mode=\"a\" with the openpyxl engine and if_sheet_exists=\"overlay\". pandas then writes only the cells covered by the DataFrame and leaves the rest of the sheet, including formatting, as it was.",{"q":2414,"a":2482},"replace deletes the existing sheet and creates a fresh empty one with the same name before writing, so titles, notes and column widths are lost. overlay writes into the existing sheet.",{"q":2420,"a":2484},"Yes. Pass header=False, and index=False if you do not want the index either. This is how you fill the data area of a template whose header row is already designed.","write a dataframe to a specific cell in excel with pandas",null,{"breadcrumb":2488},[2489,2492,2495],{"name":2490,"item":2491},"Home","\u002F",{"name":2493,"item":2494},"Getting Started with Python Excel Automation","\u002Fgetting-started-with-python-excel-automation\u002F",{"name":29,"item":28},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel",{"title":2498,"description":2499},"Write a pandas DataFrame to a Specific Cell or Row in Excel","Use to_excel startrow and startcol to position a DataFrame, write into an existing sheet with if_sheet_exists=\"overlay\", stack several tables, and convert A1 addresses to offsets.","write-a-dataframe-to-a-specific-cell-in-excel","getting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-dataframe-to-a-specific-cell-in-excel\u002Findex",[2503,2504],"writing-excel","pandas","how-to","vuHY1KX-fogSuKRs7xVTvhpJAd-HjQe-b3XIZLZSyeE",[2508,2512],{"title":2509,"path":2510,"stem":2511,"children":-1},"Round Numbers for Excel Output: float_format vs Number Formats","\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fround-numbers-for-excel-output-float-format-vs-number-formats","getting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fround-numbers-for-excel-output-float-format-vs-number-formats\u002Findex",{"title":2513,"path":2514,"stem":2515,"children":-1},"Write a List of Dictionaries to Excel Without pandas","\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-list-of-dictionaries-to-excel-without-pandas","getting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fwrite-a-list-of-dictionaries-to-excel-without-pandas\u002Findex",[2517,2519],{"path":2518,"title":2493},"\u002Fgetting-started-with-python-excel-automation",{"path":2520,"title":29},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas",[],[2523,2525,2528,2531,2534,2537],{"path":2524,"title":1949,"kind":2505},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fwrite-multiple-dataframes-to-one-excel-file",{"path":2526,"title":2527,"kind":2505},"\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",{"path":2529,"title":2530,"kind":2505},"\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",{"path":2532,"title":2533,"kind":2505},"\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",{"path":2535,"title":2536,"kind":2505},"\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",{"path":2538,"title":2539,"kind":2505},"\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",1790972077741]