[{"data":1,"prerenderedAt":2050},["ShallowReactive",2],{"doc:\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl":3,"surround:\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl":2017,"ancestors:\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl":2026,"children:\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl":2031,"related:\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl":2032},{"id":4,"title":5,"body":6,"dateModified":1982,"datePublished":1982,"description":1983,"extension":1984,"faq":1985,"keyword":1994,"kind":1995,"meta":1996,"navigation":280,"path":2005,"seo":2006,"slug":2009,"stem":2010,"topics":2011,"type":2015,"__hash__":2016},"docs\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl\u002Findex.md","Put a Chart on Its Own Chartsheet with openpyxl",{"type":7,"value":8,"toc":1969},"minimark",[9,24,166,171,196,199,203,213,912,927,931,934,1115,1137,1233,1237,1240,1470,1491,1495,1498,1649,1667,1812,1816,1824,1828,1881,1885,1888,1892,1904,1908,1914,1920,1926,1936,1940,1965],[10,11,12,13,17,18,23],"p",{},"A chart placed on a worksheet shares the grid with data: it covers cells, moves when rows are resized, and prints across page breaks unless someone lays it out carefully. Excel has a second kind of sheet for exactly this — the ",[14,15,16],"strong",{},"chartsheet",", a tab that holds one chart and nothing else. The chart fills the window at any screen size, cannot be dragged off its data, and prints as a single full page. It is the natural home for the headline chart of a report: put it first, and the workbook opens on the picture, with the numbers a tab away. This page, part of ",[19,20,22],"a",{"href":21},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002F","Creating Charts in Excel with openpyxl",", creates chartsheets with openpyxl and fixes the one default that makes them look empty outside Excel.",[25,26,34,35,34,39,34,43,34,51,34,61,34,72,34,79,34,86,34,92,34,100,34,104,34,111,34,115,34,120,34,124,34,131,34,136,34,140,34,144,34,149,34,152,34,157,34,160],"svg",{"viewBox":27,"role":28,"ariaLabelledBy":29,"xmlns":32,"style":33},"4 0 752 207","img",[30,31],"cs-vs-embedded-t","cs-vs-embedded-d","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;max-width:752px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif","\n  ",[36,37,38],"title",{"id":30},"A chart on a worksheet versus a chartsheet",[40,41,42],"desc",{"id":31},"Two panels. An embedded chart sits over cells on a worksheet: it can cover data, moves with row and column changes and needs page layout to print well, but it can sit beside the numbers. A chartsheet holds one chart only: it fills the window, cannot be moved off its place and prints as one page, while its data lives on another sheet.",[44,45],"rect",{"x":46,"y":47,"width":48,"height":49,"fill":50},"4","0","752","207","#ffffff",[44,52],{"x":53,"y":54,"width":55,"height":56,"rx":57,"fill":58,"stroke":59,"style":60},"20.0","16.0","351.0","175.0","14","#fdefd8","var(--gold,#b4740a)","stroke-width:2px",[62,63,65],"g",{"transform":64},"translate(182.5,29.0) scale(1.083)",[66,67],"path",{"d":68,"fill":69,"stroke":70,"style":71},"M4 4h16v16H4z M4 9h16 M4 14h16 M10 4v16","none","var(--gold-ink,#7a4e06)","stroke-width:1.66px;stroke-linecap:round;stroke-linejoin:round",[73,74,78],"text",{"x":75,"y":76,"style":77},"195.5","78.0","font-size:14px;font-weight:700;fill:var(--gold-ink,#7a4e06);text-anchor:middle","Chart on a worksheet",[80,81],"line",{"x1":82,"y1":83,"x2":84,"y2":83,"stroke":59,"style":85},"36.0","91.0","355.0","stroke-width:1px",[73,87,91],{"x":88,"y":89,"style":90},"60.0","111.0","font-size:12px;font-weight:400;fill:var(--text,#172033);text-anchor:start","sits beside its numbers",[62,93,95],{"transform":94},"translate(38.5,99.5) scale(0.625)",[66,96],{"d":97,"fill":69,"stroke":98,"style":99},"M5 12.5l4.5 4.5L19 7","var(--teal,#0f9488)","stroke-width:2.88px;stroke-linecap:round;stroke-linejoin:round",[73,101,103],{"x":88,"y":102,"style":90},"137.0","can cover cells",[62,105,107],{"transform":106},"translate(38.5,125.5) scale(0.625)",[66,108],{"d":109,"fill":69,"stroke":110,"style":99},"M6 6l12 12 M18 6L6 18","var(--accent,#f43f8f)",[73,112,114],{"x":88,"y":113,"style":90},"163.0","needs print layout",[62,116,118],{"transform":117},"translate(38.5,151.5) scale(0.625)",[66,119],{"d":109,"fill":69,"stroke":110,"style":99},[44,121],{"x":122,"y":54,"width":55,"height":56,"rx":57,"fill":123,"stroke":98,"style":60},"389.0","#d9f4f1",[62,125,127],{"transform":126},"translate(551.5,29.0) scale(1.083)",[66,128],{"d":129,"fill":69,"stroke":130,"style":71},"M4 20h16 M7 17v-5 M12 17V7 M17 17v-8","var(--teal-ink,#0b6157)",[73,132,135],{"x":133,"y":76,"style":134},"564.5","font-size:14px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","Chartsheet",[80,137],{"x1":138,"y1":83,"x2":139,"y2":83,"stroke":98,"style":85},"405.0","724.0",[73,141,143],{"x":142,"y":89,"style":90},"429.0","fills the whole window",[62,145,147],{"transform":146},"translate(407.5,99.5) scale(0.625)",[66,148],{"d":97,"fill":69,"stroke":98,"style":99},[73,150,151],{"x":142,"y":102,"style":90},"prints as one page",[62,153,155],{"transform":154},"translate(407.5,125.5) scale(0.625)",[66,156],{"d":97,"fill":69,"stroke":98,"style":99},[73,158,159],{"x":142,"y":113,"style":90},"data lives on another tab",[62,161,163],{"transform":162},"translate(407.5,151.5) scale(0.625)",[66,164],{"d":165,"fill":69,"stroke":59,"style":99},"M12 3.5l9.5 17h-19z M12 10v5 M12 17.8v.4",[167,168,170],"h2",{"id":169},"prerequisites","Prerequisites",[172,173,178],"pre",{"className":174,"code":175,"language":176,"meta":177,"style":177},"language-bash shiki shiki-themes github-light github-dark-high-contrast","pip install openpyxl\n","bash","",[179,180,181],"code",{"__ignoreMap":177},[182,183,185,189,193],"span",{"class":80,"line":184},1,[182,186,188],{"class":187},"sMTad","pip",[182,190,192],{"class":191},"srMev"," install",[182,194,195],{"class":191}," openpyxl\n",[10,197,198],{},"The examples chart twelve months of revenue for three regions; the data goes on a worksheet named Data.",[167,200,202],{"id":201},"step-1-create-a-chartsheet-and-give-it-a-chart","Step 1 — Create a chartsheet and give it a chart",[10,204,205,208,209,212],{},[179,206,207],{},"wb.create_chartsheet(title, index)"," adds a chartsheet at the given position. Build the chart exactly as for a worksheet — its references point at the Data sheet — and attach it with ",[179,210,211],{},"add_chart",". Unlike a worksheet, a chartsheet takes no cell anchor, because the chart occupies the whole sheet:",[172,214,218],{"className":215,"code":216,"language":217,"meta":177,"style":177},"language-python shiki shiki-themes github-light github-dark-high-contrast","from openpyxl import Workbook\nfrom openpyxl.chart import LineChart, Reference\nfrom openpyxl.drawing.xdr import XDRPositiveSize2D\nfrom openpyxl.utils.units import cm_to_EMU\n\nmonths = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\nregions = {\"North\": [42, 45, 48, 51, 55, 58, 54, 52, 60, 63, 66, 72],\n           \"South\": [30, 31, 35, 34, 38, 41, 44, 47, 45, 49, 52, 55],\n           \"East\": [12, 14, 15, 18, 20, 22, 25, 27, 30, 33, 35, 40]}\n\nwb = Workbook(); data = wb.active; data.title = \"Data\"\ndata.append([\"Month\", *regions])\nfor i, m in enumerate(months):\n    data.append([m, *(v[i] for v in regions.values())])\n\ndef revenue_chart(title, first_col, last_col):\n    chart = LineChart()\n    chart.title = title\n    chart.add_data(Reference(data, min_col=first_col, max_col=last_col, min_row=1, max_row=13), titles_from_data=True)\n    chart.set_categories(Reference(data, min_col=1, min_row=2, max_row=13))\n    chart.y_axis.title = \"Revenue (k)\"\n    chart.x_axis.delete = False\n    chart.y_axis.delete = False\n    return chart\n\noverview = wb.create_chartsheet(\"Overview\", 0)\nchart = revenue_chart(\"Revenue by region, 2026\", 2, 4)\noverview.add_chart(chart)\nchart.anchor.ext = XDRPositiveSize2D(cm_to_EMU(25), cm_to_EMU(17))\nprint(wb.sheetnames, type(chart.anchor).__name__)\n","python",[179,219,220,236,249,262,275,282,356,435,500,566,571,592,609,627,648,653,666,677,688,743,775,786,797,807,816,821,841,865,871,892],{"__ignoreMap":177},[182,221,222,226,230,233],{"class":80,"line":184},[182,223,225],{"class":224},"s-kum","from",[182,227,229],{"class":228},"skGVy"," openpyxl ",[182,231,232],{"class":224},"import",[182,234,235],{"class":228}," Workbook\n",[182,237,239,241,244,246],{"class":80,"line":238},2,[182,240,225],{"class":224},[182,242,243],{"class":228}," openpyxl.chart ",[182,245,232],{"class":224},[182,247,248],{"class":228}," LineChart, Reference\n",[182,250,252,254,257,259],{"class":80,"line":251},3,[182,253,225],{"class":224},[182,255,256],{"class":228}," openpyxl.drawing.xdr ",[182,258,232],{"class":224},[182,260,261],{"class":228}," XDRPositiveSize2D\n",[182,263,265,267,270,272],{"class":80,"line":264},4,[182,266,225],{"class":224},[182,268,269],{"class":228}," openpyxl.utils.units ",[182,271,232],{"class":224},[182,273,274],{"class":228}," cm_to_EMU\n",[182,276,278],{"class":80,"line":277},5,[182,279,281],{"emptyLinePlaceholder":280},true,"\n",[182,283,285,288,291,294,297,300,303,305,308,310,313,315,318,320,323,325,328,330,333,335,338,340,343,345,348,350,353],{"class":80,"line":284},6,[182,286,287],{"class":228},"months ",[182,289,290],{"class":224},"=",[182,292,293],{"class":228}," [",[182,295,296],{"class":191},"\"Jan\"",[182,298,299],{"class":228},", ",[182,301,302],{"class":191},"\"Feb\"",[182,304,299],{"class":228},[182,306,307],{"class":191},"\"Mar\"",[182,309,299],{"class":228},[182,311,312],{"class":191},"\"Apr\"",[182,314,299],{"class":228},[182,316,317],{"class":191},"\"May\"",[182,319,299],{"class":228},[182,321,322],{"class":191},"\"Jun\"",[182,324,299],{"class":228},[182,326,327],{"class":191},"\"Jul\"",[182,329,299],{"class":228},[182,331,332],{"class":191},"\"Aug\"",[182,334,299],{"class":228},[182,336,337],{"class":191},"\"Sep\"",[182,339,299],{"class":228},[182,341,342],{"class":191},"\"Oct\"",[182,344,299],{"class":228},[182,346,347],{"class":191},"\"Nov\"",[182,349,299],{"class":228},[182,351,352],{"class":191},"\"Dec\"",[182,354,355],{"class":228},"]\n",[182,357,359,362,364,367,370,373,377,379,382,384,387,389,392,394,397,399,402,404,407,409,412,414,417,419,422,424,427,429,432],{"class":80,"line":358},7,[182,360,361],{"class":228},"regions ",[182,363,290],{"class":224},[182,365,366],{"class":228}," {",[182,368,369],{"class":191},"\"North\"",[182,371,372],{"class":228},": [",[182,374,376],{"class":375},"sP0c6","42",[182,378,299],{"class":228},[182,380,381],{"class":375},"45",[182,383,299],{"class":228},[182,385,386],{"class":375},"48",[182,388,299],{"class":228},[182,390,391],{"class":375},"51",[182,393,299],{"class":228},[182,395,396],{"class":375},"55",[182,398,299],{"class":228},[182,400,401],{"class":375},"58",[182,403,299],{"class":228},[182,405,406],{"class":375},"54",[182,408,299],{"class":228},[182,410,411],{"class":375},"52",[182,413,299],{"class":228},[182,415,416],{"class":375},"60",[182,418,299],{"class":228},[182,420,421],{"class":375},"63",[182,423,299],{"class":228},[182,425,426],{"class":375},"66",[182,428,299],{"class":228},[182,430,431],{"class":375},"72",[182,433,434],{"class":228},"],\n",[182,436,438,441,443,446,448,451,453,456,458,461,463,466,468,471,473,476,478,481,483,485,487,490,492,494,496,498],{"class":80,"line":437},8,[182,439,440],{"class":191},"           \"South\"",[182,442,372],{"class":228},[182,444,445],{"class":375},"30",[182,447,299],{"class":228},[182,449,450],{"class":375},"31",[182,452,299],{"class":228},[182,454,455],{"class":375},"35",[182,457,299],{"class":228},[182,459,460],{"class":375},"34",[182,462,299],{"class":228},[182,464,465],{"class":375},"38",[182,467,299],{"class":228},[182,469,470],{"class":375},"41",[182,472,299],{"class":228},[182,474,475],{"class":375},"44",[182,477,299],{"class":228},[182,479,480],{"class":375},"47",[182,482,299],{"class":228},[182,484,381],{"class":375},[182,486,299],{"class":228},[182,488,489],{"class":375},"49",[182,491,299],{"class":228},[182,493,411],{"class":375},[182,495,299],{"class":228},[182,497,396],{"class":375},[182,499,434],{"class":228},[182,501,503,506,508,511,513,515,517,520,522,525,527,530,532,535,537,540,542,545,547,549,551,554,556,558,560,563],{"class":80,"line":502},9,[182,504,505],{"class":191},"           \"East\"",[182,507,372],{"class":228},[182,509,510],{"class":375},"12",[182,512,299],{"class":228},[182,514,57],{"class":375},[182,516,299],{"class":228},[182,518,519],{"class":375},"15",[182,521,299],{"class":228},[182,523,524],{"class":375},"18",[182,526,299],{"class":228},[182,528,529],{"class":375},"20",[182,531,299],{"class":228},[182,533,534],{"class":375},"22",[182,536,299],{"class":228},[182,538,539],{"class":375},"25",[182,541,299],{"class":228},[182,543,544],{"class":375},"27",[182,546,299],{"class":228},[182,548,445],{"class":375},[182,550,299],{"class":228},[182,552,553],{"class":375},"33",[182,555,299],{"class":228},[182,557,455],{"class":375},[182,559,299],{"class":228},[182,561,562],{"class":375},"40",[182,564,565],{"class":228},"]}\n",[182,567,569],{"class":80,"line":568},10,[182,570,281],{"emptyLinePlaceholder":280},[182,572,574,577,579,582,584,587,589],{"class":80,"line":573},11,[182,575,576],{"class":228},"wb ",[182,578,290],{"class":224},[182,580,581],{"class":228}," Workbook(); data ",[182,583,290],{"class":224},[182,585,586],{"class":228}," wb.active; data.title ",[182,588,290],{"class":224},[182,590,591],{"class":191}," \"Data\"\n",[182,593,595,598,601,603,606],{"class":80,"line":594},12,[182,596,597],{"class":228},"data.append([",[182,599,600],{"class":191},"\"Month\"",[182,602,299],{"class":228},[182,604,605],{"class":224},"*",[182,607,608],{"class":228},"regions])\n",[182,610,612,615,618,621,624],{"class":80,"line":611},13,[182,613,614],{"class":224},"for",[182,616,617],{"class":228}," i, m ",[182,619,620],{"class":224},"in",[182,622,623],{"class":375}," enumerate",[182,625,626],{"class":228},"(months):\n",[182,628,630,633,635,638,640,643,645],{"class":80,"line":629},14,[182,631,632],{"class":228},"    data.append([m, ",[182,634,605],{"class":224},[182,636,637],{"class":228},"(v[i] ",[182,639,614],{"class":224},[182,641,642],{"class":228}," v ",[182,644,620],{"class":224},[182,646,647],{"class":228}," regions.values())])\n",[182,649,651],{"class":80,"line":650},15,[182,652,281],{"emptyLinePlaceholder":280},[182,654,656,659,663],{"class":80,"line":655},16,[182,657,658],{"class":224},"def",[182,660,662],{"class":661},"s_Opv"," revenue_chart",[182,664,665],{"class":228},"(title, first_col, last_col):\n",[182,667,669,672,674],{"class":80,"line":668},17,[182,670,671],{"class":228},"    chart ",[182,673,290],{"class":224},[182,675,676],{"class":228}," LineChart()\n",[182,678,680,683,685],{"class":80,"line":679},18,[182,681,682],{"class":228},"    chart.title ",[182,684,290],{"class":224},[182,686,687],{"class":228}," title\n",[182,689,691,694,698,700,703,706,708,711,714,716,719,721,724,726,729,732,735,737,740],{"class":80,"line":690},19,[182,692,693],{"class":228},"    chart.add_data(Reference(data, ",[182,695,697],{"class":696},"sa561","min_col",[182,699,290],{"class":224},[182,701,702],{"class":228},"first_col, ",[182,704,705],{"class":696},"max_col",[182,707,290],{"class":224},[182,709,710],{"class":228},"last_col, ",[182,712,713],{"class":696},"min_row",[182,715,290],{"class":224},[182,717,718],{"class":375},"1",[182,720,299],{"class":228},[182,722,723],{"class":696},"max_row",[182,725,290],{"class":224},[182,727,728],{"class":375},"13",[182,730,731],{"class":228},"), ",[182,733,734],{"class":696},"titles_from_data",[182,736,290],{"class":224},[182,738,739],{"class":375},"True",[182,741,742],{"class":228},")\n",[182,744,746,749,751,753,755,757,759,761,764,766,768,770,772],{"class":80,"line":745},20,[182,747,748],{"class":228},"    chart.set_categories(Reference(data, ",[182,750,697],{"class":696},[182,752,290],{"class":224},[182,754,718],{"class":375},[182,756,299],{"class":228},[182,758,713],{"class":696},[182,760,290],{"class":224},[182,762,763],{"class":375},"2",[182,765,299],{"class":228},[182,767,723],{"class":696},[182,769,290],{"class":224},[182,771,728],{"class":375},[182,773,774],{"class":228},"))\n",[182,776,778,781,783],{"class":80,"line":777},21,[182,779,780],{"class":228},"    chart.y_axis.title ",[182,782,290],{"class":224},[182,784,785],{"class":191}," \"Revenue (k)\"\n",[182,787,789,792,794],{"class":80,"line":788},22,[182,790,791],{"class":228},"    chart.x_axis.delete ",[182,793,290],{"class":224},[182,795,796],{"class":375}," False\n",[182,798,800,803,805],{"class":80,"line":799},23,[182,801,802],{"class":228},"    chart.y_axis.delete ",[182,804,290],{"class":224},[182,806,796],{"class":375},[182,808,810,813],{"class":80,"line":809},24,[182,811,812],{"class":224},"    return",[182,814,815],{"class":228}," chart\n",[182,817,819],{"class":80,"line":818},25,[182,820,281],{"emptyLinePlaceholder":280},[182,822,824,827,829,832,835,837,839],{"class":80,"line":823},26,[182,825,826],{"class":228},"overview ",[182,828,290],{"class":224},[182,830,831],{"class":228}," wb.create_chartsheet(",[182,833,834],{"class":191},"\"Overview\"",[182,836,299],{"class":228},[182,838,47],{"class":375},[182,840,742],{"class":228},[182,842,844,847,849,852,855,857,859,861,863],{"class":80,"line":843},27,[182,845,846],{"class":228},"chart ",[182,848,290],{"class":224},[182,850,851],{"class":228}," revenue_chart(",[182,853,854],{"class":191},"\"Revenue by region, 2026\"",[182,856,299],{"class":228},[182,858,763],{"class":375},[182,860,299],{"class":228},[182,862,46],{"class":375},[182,864,742],{"class":228},[182,866,868],{"class":80,"line":867},28,[182,869,870],{"class":228},"overview.add_chart(chart)\n",[182,872,874,877,879,882,884,887,890],{"class":80,"line":873},29,[182,875,876],{"class":228},"chart.anchor.ext ",[182,878,290],{"class":224},[182,880,881],{"class":228}," XDRPositiveSize2D(cm_to_EMU(",[182,883,539],{"class":375},[182,885,886],{"class":228},"), cm_to_EMU(",[182,888,889],{"class":375},"17",[182,891,774],{"class":228},[182,893,895,898,901,904,907,910],{"class":80,"line":894},30,[182,896,897],{"class":375},"print",[182,899,900],{"class":228},"(wb.sheetnames, ",[182,902,903],{"class":375},"type",[182,905,906],{"class":228},"(chart.anchor).",[182,908,909],{"class":375},"__name__",[182,911,742],{"class":228},[10,913,914,915,917,918,921,922,926],{},"Index ",[179,916,47],{}," puts Overview first, so the workbook's first tab is the chart. The last line matters outside Excel: openpyxl records the chart's size on a chartsheet as zero. Excel ignores it and stretches the chart to fill the sheet, but LibreOffice and other applications draw the chart at its stored size — a dot in the corner of an empty page. Setting the anchor's extent to a real size, in EMUs (English Metric Units, 360,000 per centimetre), makes the sheet look right everywhere; Excel still scales it to the window. The ",[179,919,920],{},"delete = False"," lines keep the axes visible in Excel, as explained in ",[19,923,925],{"href":924},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fformat-chart-axes-with-openpyxl\u002F","Format Chart Axes with openpyxl",".",[167,928,930],{"id":929},"step-2-one-chartsheet-per-region","Step 2 — One chartsheet per region",[10,932,933],{},"Chartsheets suit a set of parallel charts — one per region, product or department — each a tab of its own that readers flip through. Create them in a loop, after the overview:",[172,935,937],{"className":215,"code":936,"language":217,"meta":177,"style":177},"for position, (name, col) in enumerate(zip(regions, range(2, 5)), start=1):\n    sheet = wb.create_chartsheet(f\"{name} chart\", position)\n    region_chart = revenue_chart(f\"{name} revenue, 2026\", col, col)\n    region_chart.legend = None\n    sheet.add_chart(region_chart)\n    region_chart.anchor.ext = XDRPositiveSize2D(cm_to_EMU(25), cm_to_EMU(17))\nprint(wb.sheetnames)\nprint(\"chartsheets:\", [s.title for s in wb.chartsheets], \"| worksheets:\", [s.title for s in wb.worksheets])\n",[179,938,939,984,1015,1040,1050,1055,1072,1079],{"__ignoreMap":177},[182,940,941,943,946,948,950,953,956,959,962,964,966,968,971,974,977,979,981],{"class":80,"line":184},[182,942,614],{"class":224},[182,944,945],{"class":228}," position, (name, col) ",[182,947,620],{"class":224},[182,949,623],{"class":375},[182,951,952],{"class":228},"(",[182,954,955],{"class":375},"zip",[182,957,958],{"class":228},"(regions, ",[182,960,961],{"class":375},"range",[182,963,952],{"class":228},[182,965,763],{"class":375},[182,967,299],{"class":228},[182,969,970],{"class":375},"5",[182,972,973],{"class":228},")), ",[182,975,976],{"class":696},"start",[182,978,290],{"class":224},[182,980,718],{"class":375},[182,982,983],{"class":228},"):\n",[182,985,986,989,991,993,996,999,1003,1006,1009,1012],{"class":80,"line":238},[182,987,988],{"class":228},"    sheet ",[182,990,290],{"class":224},[182,992,831],{"class":228},[182,994,995],{"class":224},"f",[182,997,998],{"class":191},"\"",[182,1000,1002],{"class":1001},"sSjpA","{",[182,1004,1005],{"class":228},"name",[182,1007,1008],{"class":1001},"}",[182,1010,1011],{"class":191}," chart\"",[182,1013,1014],{"class":228},", position)\n",[182,1016,1017,1020,1022,1024,1026,1028,1030,1032,1034,1037],{"class":80,"line":251},[182,1018,1019],{"class":228},"    region_chart ",[182,1021,290],{"class":224},[182,1023,851],{"class":228},[182,1025,995],{"class":224},[182,1027,998],{"class":191},[182,1029,1002],{"class":1001},[182,1031,1005],{"class":228},[182,1033,1008],{"class":1001},[182,1035,1036],{"class":191}," revenue, 2026\"",[182,1038,1039],{"class":228},", col, col)\n",[182,1041,1042,1045,1047],{"class":80,"line":264},[182,1043,1044],{"class":228},"    region_chart.legend ",[182,1046,290],{"class":224},[182,1048,1049],{"class":375}," None\n",[182,1051,1052],{"class":80,"line":277},[182,1053,1054],{"class":228},"    sheet.add_chart(region_chart)\n",[182,1056,1057,1060,1062,1064,1066,1068,1070],{"class":80,"line":284},[182,1058,1059],{"class":228},"    region_chart.anchor.ext ",[182,1061,290],{"class":224},[182,1063,881],{"class":228},[182,1065,539],{"class":375},[182,1067,886],{"class":228},[182,1069,889],{"class":375},[182,1071,774],{"class":228},[182,1073,1074,1076],{"class":80,"line":358},[182,1075,897],{"class":375},[182,1077,1078],{"class":228},"(wb.sheetnames)\n",[182,1080,1081,1083,1085,1088,1091,1093,1096,1098,1101,1104,1106,1108,1110,1112],{"class":80,"line":437},[182,1082,897],{"class":375},[182,1084,952],{"class":228},[182,1086,1087],{"class":191},"\"chartsheets:\"",[182,1089,1090],{"class":228},", [s.title ",[182,1092,614],{"class":224},[182,1094,1095],{"class":228}," s ",[182,1097,620],{"class":224},[182,1099,1100],{"class":228}," wb.chartsheets], ",[182,1102,1103],{"class":191},"\"| worksheets:\"",[182,1105,1090],{"class":228},[182,1107,614],{"class":224},[182,1109,1095],{"class":228},[182,1111,620],{"class":224},[182,1113,1114],{"class":228}," wb.worksheets])\n",[10,1116,1117,1118,1121,1122,1125,1126,1129,1130,1133,1134,1136],{},"The four chart tabs come first and Data last. ",[179,1119,1120],{},"wb.chartsheets"," and ",[179,1123,1124],{},"wb.worksheets"," list the two kinds separately, which matters when a later step loops over \"all sheets\" to format cells — a chartsheet has no cells, and ",[179,1127,1128],{},"chartsheet[\"A1\"]"," raises a ",[179,1131,1132],{},"TypeError",". A chartsheet is meant for exactly one chart. openpyxl will accept a second ",[179,1135,211],{}," call, but both charts are anchored at the same corner and drawn on top of each other, so make a new sheet per chart.",[25,1138,34,1144,34,1147,34,1150,34,1155,34,1162,34,1169,34,1175,34,1180,34,1185,34,1190,34,1194,34,1200,34,1205,34,1209,34,1213,34,1216,34,1219,34,1224,34,1229],{"viewBox":1139,"role":28,"ariaLabelledBy":1140,"xmlns":32,"style":1143},"84 0 592 383",[1141,1142],"cs-tabs-t","cs-tabs-d","width:100%;max-width:592px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif",[36,1145,1146],{"id":1141},"The workbook's tabs, chart first",[40,1148,1149],{"id":1142},"The order of the tabs in the finished workbook. First the Overview chartsheet with all three regions, then one chartsheet each for North, South and East, and last the Data worksheet that every chart references.",[44,1151],{"x":1152,"y":47,"width":1153,"height":1154,"fill":50},"84","592","383",[44,1156],{"x":1157,"y":54,"width":1158,"height":1159,"rx":510,"fill":1160,"stroke":1161,"style":60},"100.0","560.0","93.0","#e7ebef","var(--line,#cdd5e6)",[62,1163,1165],{"transform":1164},"translate(368.0,29.0) scale(1.000)",[66,1166],{"d":68,"fill":69,"stroke":1167,"style":1168},"var(--text,#172033)","stroke-width:1.80px;stroke-linecap:round;stroke-linejoin:round",[73,1170,1174],{"x":1171,"y":1172,"style":1173},"380.0","75.5","font-size:13.5px;font-weight:700;fill:var(--text,#172033);text-anchor:middle","Data",[73,1176,1179],{"x":1171,"y":1177,"style":1178},"95.0","font-size:11.5px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","worksheet — the numbers every chart uses",[80,1181],{"x1":1171,"y1":1182,"x2":1171,"y2":1183,"stroke":1184,"style":60},"114.0","136.0","var(--brand,#5b5cf0)",[1186,1187],"polygon",{"points":1188,"fill":1189},"380.0,140.0 375.0,131.0 385.0,131.0","#5b5cf0",[44,1191],{"x":1157,"y":1192,"width":1158,"height":1159,"rx":510,"fill":1193,"stroke":1184,"style":60},"145.0","#f0f4ff",[62,1195,1197],{"transform":1196},"translate(368.0,158.0) scale(1.000)",[66,1198],{"d":129,"fill":69,"stroke":1199,"style":1168},"var(--brand-strong,#4338ca)",[73,1201,1204],{"x":1171,"y":1202,"style":1203},"204.5","font-size:13.5px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","North, South, East chart",[73,1206,1208],{"x":1171,"y":1207,"style":1178},"224.0","one chartsheet per region",[80,1210],{"x1":1171,"y1":1211,"x2":1171,"y2":1212,"stroke":1184,"style":60},"243.0","265.0",[1186,1214],{"points":1215,"fill":1189},"380.0,269.0 375.0,260.0 385.0,260.0",[44,1217],{"x":1157,"y":1218,"width":1158,"height":1159,"rx":510,"fill":123,"stroke":98,"style":60},"274.0",[62,1220,1222],{"transform":1221},"translate(368.0,287.0) scale(1.000)",[66,1223],{"d":129,"fill":69,"stroke":130,"style":1168},[73,1225,1228],{"x":1171,"y":1226,"style":1227},"333.5","font-size:13.5px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","Overview",[73,1230,1232],{"x":1171,"y":1231,"style":1178},"353.0","first tab — opens on the picture",[167,1234,1236],{"id":1235},"step-3-colour-the-tabs-set-printing-and-protect","Step 3 — Colour the tabs, set printing and protect",[10,1238,1239],{},"Chartsheets have their own property, protection and page-setup objects, which start empty in openpyxl and are created rather than edited:",[172,1241,1243],{"className":215,"code":1242,"language":217,"meta":177,"style":177},"from openpyxl.chartsheet.properties import ChartsheetProperties\nfrom openpyxl.chartsheet.protection import ChartsheetProtection\nfrom openpyxl.styles.colors import Color\nfrom openpyxl.worksheet.page import PrintPageSetup\n\nfor sheet in wb.chartsheets:\n    sheet.sheetPr = ChartsheetProperties(tabColor=Color(\"0B6157\" if sheet.title == \"Overview\" else \"5B6780\"))\n    sheet.pageSetup = PrintPageSetup(orientation=\"landscape\", paperSize=9)\n    sheet.sheetProtection = ChartsheetProtection(content=True)\nwb.active = 0\nwb.save(\"revenue_chartsheets.xlsx\")\n\nfrom openpyxl import load_workbook\ncheck = load_workbook(\"revenue_chartsheets.xlsx\")\nprint([(s.title, s.sheetProtection.content) for s in check.chartsheets], \"| opens on:\", check.active.title)\n",[179,1244,1245,1257,1269,1281,1293,1297,1309,1350,1380,1399,1409,1419,1423,1434,1448],{"__ignoreMap":177},[182,1246,1247,1249,1252,1254],{"class":80,"line":184},[182,1248,225],{"class":224},[182,1250,1251],{"class":228}," openpyxl.chartsheet.properties ",[182,1253,232],{"class":224},[182,1255,1256],{"class":228}," ChartsheetProperties\n",[182,1258,1259,1261,1264,1266],{"class":80,"line":238},[182,1260,225],{"class":224},[182,1262,1263],{"class":228}," openpyxl.chartsheet.protection ",[182,1265,232],{"class":224},[182,1267,1268],{"class":228}," ChartsheetProtection\n",[182,1270,1271,1273,1276,1278],{"class":80,"line":251},[182,1272,225],{"class":224},[182,1274,1275],{"class":228}," openpyxl.styles.colors ",[182,1277,232],{"class":224},[182,1279,1280],{"class":228}," Color\n",[182,1282,1283,1285,1288,1290],{"class":80,"line":264},[182,1284,225],{"class":224},[182,1286,1287],{"class":228}," openpyxl.worksheet.page ",[182,1289,232],{"class":224},[182,1291,1292],{"class":228}," PrintPageSetup\n",[182,1294,1295],{"class":80,"line":277},[182,1296,281],{"emptyLinePlaceholder":280},[182,1298,1299,1301,1304,1306],{"class":80,"line":284},[182,1300,614],{"class":224},[182,1302,1303],{"class":228}," sheet ",[182,1305,620],{"class":224},[182,1307,1308],{"class":228}," wb.chartsheets:\n",[182,1310,1311,1314,1316,1319,1322,1324,1327,1330,1333,1336,1339,1342,1345,1348],{"class":80,"line":358},[182,1312,1313],{"class":228},"    sheet.sheetPr ",[182,1315,290],{"class":224},[182,1317,1318],{"class":228}," ChartsheetProperties(",[182,1320,1321],{"class":696},"tabColor",[182,1323,290],{"class":224},[182,1325,1326],{"class":228},"Color(",[182,1328,1329],{"class":191},"\"0B6157\"",[182,1331,1332],{"class":224}," if",[182,1334,1335],{"class":228}," sheet.title ",[182,1337,1338],{"class":224},"==",[182,1340,1341],{"class":191}," \"Overview\"",[182,1343,1344],{"class":224}," else",[182,1346,1347],{"class":191}," \"5B6780\"",[182,1349,774],{"class":228},[182,1351,1352,1355,1357,1360,1363,1365,1368,1370,1373,1375,1378],{"class":80,"line":437},[182,1353,1354],{"class":228},"    sheet.pageSetup ",[182,1356,290],{"class":224},[182,1358,1359],{"class":228}," PrintPageSetup(",[182,1361,1362],{"class":696},"orientation",[182,1364,290],{"class":224},[182,1366,1367],{"class":191},"\"landscape\"",[182,1369,299],{"class":228},[182,1371,1372],{"class":696},"paperSize",[182,1374,290],{"class":224},[182,1376,1377],{"class":375},"9",[182,1379,742],{"class":228},[182,1381,1382,1385,1387,1390,1393,1395,1397],{"class":80,"line":502},[182,1383,1384],{"class":228},"    sheet.sheetProtection ",[182,1386,290],{"class":224},[182,1388,1389],{"class":228}," ChartsheetProtection(",[182,1391,1392],{"class":696},"content",[182,1394,290],{"class":224},[182,1396,739],{"class":375},[182,1398,742],{"class":228},[182,1400,1401,1404,1406],{"class":80,"line":568},[182,1402,1403],{"class":228},"wb.active ",[182,1405,290],{"class":224},[182,1407,1408],{"class":375}," 0\n",[182,1410,1411,1414,1417],{"class":80,"line":573},[182,1412,1413],{"class":228},"wb.save(",[182,1415,1416],{"class":191},"\"revenue_chartsheets.xlsx\"",[182,1418,742],{"class":228},[182,1420,1421],{"class":80,"line":594},[182,1422,281],{"emptyLinePlaceholder":280},[182,1424,1425,1427,1429,1431],{"class":80,"line":611},[182,1426,225],{"class":224},[182,1428,229],{"class":228},[182,1430,232],{"class":224},[182,1432,1433],{"class":228}," load_workbook\n",[182,1435,1436,1439,1441,1444,1446],{"class":80,"line":629},[182,1437,1438],{"class":228},"check ",[182,1440,290],{"class":224},[182,1442,1443],{"class":228}," load_workbook(",[182,1445,1416],{"class":191},[182,1447,742],{"class":228},[182,1449,1450,1452,1455,1457,1459,1461,1464,1467],{"class":80,"line":650},[182,1451,897],{"class":375},[182,1453,1454],{"class":228},"([(s.title, s.sheetProtection.content) ",[182,1456,614],{"class":224},[182,1458,1095],{"class":228},[182,1460,620],{"class":224},[182,1462,1463],{"class":228}," check.chartsheets], ",[182,1465,1466],{"class":191},"\"| opens on:\"",[182,1468,1469],{"class":228},", check.active.title)\n",[10,1471,1472,1475,1476,1478,1479,1482,1483,1486,1487,1490],{},[179,1473,1474],{},"paperSize=9"," is A4 (use ",[179,1477,718],{}," for US Letter); landscape suits most charts. Protecting the content stops readers changing the chart's formatting by accident while leaving the data sheet editable — add ",[179,1480,1481],{},"password=..."," to ",[179,1484,1485],{},"ChartsheetProtection"," for a light deterrent, remembering that sheet passwords are not security. ",[179,1488,1489],{},"wb.active = 0"," makes the workbook open on the Overview tab.",[167,1492,1494],{"id":1493},"step-4-read-and-update-chartsheets-later","Step 4 — Read and update chartsheets later",[10,1496,1497],{},"openpyxl reads chartsheets and the charts on them back, so a template workbook with chart tabs can be refilled: write new numbers to the Data sheet and save, and every chart updates because it references cells, not copies of values:",[172,1499,1501],{"className":215,"code":1500,"language":217,"meta":177,"style":177},"wb2 = load_workbook(\"revenue_chartsheets.xlsx\")\nws = wb2[\"Data\"]\nfor row in ws.iter_rows(min_row=2, max_row=13, min_col=2, max_col=4):\n    for cell in row:\n        cell.value = round(cell.value * 1.1)\nwb2.save(\"revenue_chartsheets_updated.xlsx\")\nprint([len(s._charts) for s in load_workbook(\"revenue_chartsheets_updated.xlsx\").chartsheets], \"chart per chartsheet after saving\")\n",[179,1502,1503,1516,1531,1575,1588,1608,1618],{"__ignoreMap":177},[182,1504,1505,1508,1510,1512,1514],{"class":80,"line":184},[182,1506,1507],{"class":228},"wb2 ",[182,1509,290],{"class":224},[182,1511,1443],{"class":228},[182,1513,1416],{"class":191},[182,1515,742],{"class":228},[182,1517,1518,1521,1523,1526,1529],{"class":80,"line":238},[182,1519,1520],{"class":228},"ws ",[182,1522,290],{"class":224},[182,1524,1525],{"class":228}," wb2[",[182,1527,1528],{"class":191},"\"Data\"",[182,1530,355],{"class":228},[182,1532,1533,1535,1538,1540,1543,1545,1547,1549,1551,1553,1555,1557,1559,1561,1563,1565,1567,1569,1571,1573],{"class":80,"line":251},[182,1534,614],{"class":224},[182,1536,1537],{"class":228}," row ",[182,1539,620],{"class":224},[182,1541,1542],{"class":228}," ws.iter_rows(",[182,1544,713],{"class":696},[182,1546,290],{"class":224},[182,1548,763],{"class":375},[182,1550,299],{"class":228},[182,1552,723],{"class":696},[182,1554,290],{"class":224},[182,1556,728],{"class":375},[182,1558,299],{"class":228},[182,1560,697],{"class":696},[182,1562,290],{"class":224},[182,1564,763],{"class":375},[182,1566,299],{"class":228},[182,1568,705],{"class":696},[182,1570,290],{"class":224},[182,1572,46],{"class":375},[182,1574,983],{"class":228},[182,1576,1577,1580,1583,1585],{"class":80,"line":264},[182,1578,1579],{"class":224},"    for",[182,1581,1582],{"class":228}," cell ",[182,1584,620],{"class":224},[182,1586,1587],{"class":228}," row:\n",[182,1589,1590,1593,1595,1598,1601,1603,1606],{"class":80,"line":277},[182,1591,1592],{"class":228},"        cell.value ",[182,1594,290],{"class":224},[182,1596,1597],{"class":375}," round",[182,1599,1600],{"class":228},"(cell.value ",[182,1602,605],{"class":224},[182,1604,1605],{"class":375}," 1.1",[182,1607,742],{"class":228},[182,1609,1610,1613,1616],{"class":80,"line":284},[182,1611,1612],{"class":228},"wb2.save(",[182,1614,1615],{"class":191},"\"revenue_chartsheets_updated.xlsx\"",[182,1617,742],{"class":228},[182,1619,1620,1622,1625,1628,1631,1633,1635,1637,1639,1641,1644,1647],{"class":80,"line":358},[182,1621,897],{"class":375},[182,1623,1624],{"class":228},"([",[182,1626,1627],{"class":375},"len",[182,1629,1630],{"class":228},"(s._charts) ",[182,1632,614],{"class":224},[182,1634,1095],{"class":228},[182,1636,620],{"class":224},[182,1638,1443],{"class":228},[182,1640,1615],{"class":191},[182,1642,1643],{"class":228},").chartsheets], ",[182,1645,1646],{"class":191},"\"chart per chartsheet after saving\"",[182,1648,742],{"class":228},[10,1650,1651,1652,1655,1656,1121,1659,1662,1663,926],{},"Each chartsheet still carries its chart after the round trip, now showing the updated figures. Changing the ",[1653,1654,961],"em",{}," a chart covers — adding a thirteenth month — means rebuilding its references, which is easiest done by recreating the chart. For the same result with xlsxwriter, which writes new files only, use ",[179,1657,1658],{},"workbook.add_chartsheet()",[179,1660,1661],{},"chartsheet.set_chart(chart)","; see ",[19,1664,1666],{"href":1665},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter\u002Fadd-a-chart-to-an-excel-file-with-xlsxwriter\u002F","Add a Chart to an Excel File with xlsxwriter",[25,1668,34,1673,34,1676,34,1679,34,1682,34,1686,34,1691,34,1697,34,1700,34,1704,34,1708,34,1713,34,1715,34,1719,34,1721,34,1724,34,1727,34,1731,34,1733,34,1736,34,1738,34,1741,34,1744,34,1748,34,1750,34,1753,34,1755,34,1758,34,1761,34,1765,34,1767,34,1771,34,1773,34,1776,34,1779,34,1783,34,1785,34,1789,34,1791,34,1794,34,1797,34,1801,34,1803,34,1807,34,1809],{"viewBox":1669,"role":28,"ariaLabelledBy":1670,"xmlns":32,"style":33},"4 0 752 276",[1671,1672],"cs-api-t","cs-api-d",[36,1674,1675],{"id":1671},"Chartsheet settings in openpyxl",[40,1677,1678],{"id":1672},"A table of chartsheet settings. create_chartsheet with a title and index adds and positions the sheet. add_chart attaches its single chart. anchor.ext sets the chart size for applications other than Excel. sheetPr with ChartsheetProperties sets the tab colour. pageSetup with PrintPageSetup sets orientation and paper. sheetProtection with ChartsheetProtection locks the chart.",[44,1680],{"x":46,"y":47,"width":48,"height":1681,"fill":50},"276",[44,1683],{"x":53,"y":54,"width":1684,"height":1685,"rx":47,"fill":50,"stroke":1161,"style":85},"107.7","40.0",[44,1687],{"x":1688,"y":54,"width":1689,"height":1685,"rx":47,"fill":1193,"stroke":1184,"style":1690},"127.7","306.1","stroke-width:1.2px",[73,1692,1696],{"x":1693,"y":1694,"style":1695},"280.8","41.0","font-size:13px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","openpyxl call",[44,1698],{"x":1699,"y":54,"width":1689,"height":1685,"rx":47,"fill":1193,"stroke":1184,"style":1690},"433.9",[73,1701,1703],{"x":1702,"y":1694,"style":1695},"586.9","Purpose",[44,1705],{"x":53,"y":1706,"width":1684,"height":1707,"rx":47,"fill":1160,"stroke":1161,"style":85},"56.0","34.0",[73,1709,1712],{"x":1710,"y":76,"style":1711},"32.0","font-size:12.5px;font-weight:700;fill:var(--text,#172033);text-anchor:start","Add sheet",[44,1714],{"x":1688,"y":1706,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1716,1718],{"x":1693,"y":1717,"style":1178},"77.0","wb.create_chartsheet(title, i)",[44,1720],{"x":1699,"y":1706,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1722,1723],{"x":1702,"y":1717,"style":1178},"position in the tabs",[44,1725],{"x":53,"y":1726,"width":1684,"height":1707,"rx":47,"fill":1160,"stroke":1161,"style":85},"90.0",[73,1728,1730],{"x":1710,"y":1729,"style":1711},"112.0","Attach chart",[44,1732],{"x":1688,"y":1726,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1734,1735],{"x":1693,"y":89,"style":1178},"sheet.add_chart(chart)",[44,1737],{"x":1699,"y":1726,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1739,1740],{"x":1702,"y":89,"style":1178},"one chart per sheet",[44,1742],{"x":53,"y":1743,"width":1684,"height":1707,"rx":47,"fill":1160,"stroke":1161,"style":85},"124.0",[73,1745,1747],{"x":1710,"y":1746,"style":1711},"146.0","Size",[44,1749],{"x":1688,"y":1743,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1751,1752],{"x":1693,"y":1192,"style":1178},"chart.anchor.ext",[44,1754],{"x":1699,"y":1743,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1756,1757],{"x":1702,"y":1192,"style":1178},"shows outside Excel",[44,1759],{"x":53,"y":1760,"width":1684,"height":1707,"rx":47,"fill":1160,"stroke":1161,"style":85},"158.0",[73,1762,1764],{"x":1710,"y":1763,"style":1711},"180.0","Tab colour",[44,1766],{"x":1688,"y":1760,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1768,1770],{"x":1693,"y":1769,"style":1178},"179.0","ChartsheetProperties(tabColor=)",[44,1772],{"x":1699,"y":1760,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1774,1775],{"x":1702,"y":1769,"style":1178},"group the tabs",[44,1777],{"x":53,"y":1778,"width":1684,"height":1707,"rx":47,"fill":1160,"stroke":1161,"style":85},"192.0",[73,1780,1782],{"x":1710,"y":1781,"style":1711},"214.0","Printing",[44,1784],{"x":1688,"y":1778,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1786,1788],{"x":1693,"y":1787,"style":1178},"213.0","PrintPageSetup(orientation=)",[44,1790],{"x":1699,"y":1778,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1792,1793],{"x":1702,"y":1787,"style":1178},"landscape page",[44,1795],{"x":53,"y":1796,"width":1684,"height":1707,"rx":47,"fill":1160,"stroke":1161,"style":85},"226.0",[73,1798,1800],{"x":1710,"y":1799,"style":1711},"248.0","Protection",[44,1802],{"x":1688,"y":1796,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1804,1806],{"x":1693,"y":1805,"style":1178},"247.0","ChartsheetProtection(content=True)",[44,1808],{"x":1699,"y":1796,"width":1689,"height":1707,"rx":47,"fill":50,"stroke":1161,"style":85},[73,1810,1811],{"x":1702,"y":1805,"style":1178},"no accidental edits",[167,1813,1815],{"id":1814},"when-a-chartsheet-is-the-right-choice","When a chartsheet is the right choice",[10,1817,1818,1819,1823],{},"Chartsheets work best for a small number of headline charts that people look at rather than work with: the chart a manager opens the workbook to see, a set of parallel region charts to flip through, a page to print for a meeting. They are the wrong choice when readers need the chart and its numbers side by side, or several small charts compared on one screen — a dashboard sheet with embedded charts does that better, as ",[19,1820,1822],{"href":1821},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002F","Building Multi-Sheet Excel Dashboards"," shows. Many reports use both: a chartsheet first for the headline, then a dashboard worksheet, then the data. Name chart tabs so their purpose is obvious from the tab bar — \"Overview\" and \"North chart\" rather than \"Chart1\" — because a chartsheet has no cells to hold a heading.",[167,1825,1827],{"id":1826},"common-pitfalls","Common pitfalls",[1829,1830,1831,1843,1851,1860,1869,1875],"ul",{},[1832,1833,1834,1837,1838,1840,1841,926],"li",{},[14,1835,1836],{},"Empty-looking chartsheets outside Excel."," Set ",[179,1839,1752],{}," after ",[179,1842,211],{},[1832,1844,1845,1837,1848,1850],{},[14,1846,1847],{},"Missing axes in Excel.",[179,1849,920],{}," on both axes, as for any openpyxl chart.",[1832,1852,1853,1859],{},[14,1854,1855,1856,926],{},"Editing sheet properties that are ",[179,1857,1858],{},"None"," Chartsheet properties, protection and page setup must be created, not modified.",[1832,1861,1862,1865,1866,1868],{},[14,1863,1864],{},"Looping over every sheet to format cells."," Use ",[179,1867,1124],{},"; chartsheets have no cells.",[1832,1870,1871,1874],{},[14,1872,1873],{},"Several charts on one chartsheet."," They overlap at the same corner; create another sheet for the next chart.",[1832,1876,1877,1880],{},[14,1878,1879],{},"Data on the same tab."," A chartsheet cannot hold data; reference a worksheet.",[167,1882,1884],{"id":1883},"performance-notes","Performance notes",[10,1886,1887],{},"Chartsheets add a sheet, a drawing and a chart part each — a few kilobytes. Dozens of chart tabs are fine; hundreds make the tab bar unusable before they make the file slow.",[167,1889,1891],{"id":1890},"conclusion","Conclusion",[10,1893,1894,1895,1897,1898,1900,1901,1903],{},"Create a chartsheet with ",[179,1896,207],{},", build its chart from references to a data worksheet, attach it with ",[179,1899,211],{},", and set ",[179,1902,1752],{}," so applications other than Excel draw it at full size. Loop to make one chartsheet per group, set tab colours, landscape printing and protection by assigning new property objects, and make the headline chart the active first tab. Refill the data sheet later and the chartsheets follow.",[167,1905,1907],{"id":1906},"frequently-asked-questions","Frequently asked questions",[10,1909,1910,1913],{},[14,1911,1912],{},"What is a chartsheet in Excel?","\nA sheet that holds a single chart and no cells. The chart fills the window, stays in place, and prints on a full page. Its data lives on an ordinary worksheet elsewhere in the workbook.",[10,1915,1916,1919],{},[14,1917,1918],{},"How do I create a chartsheet with openpyxl?","\nCall wb.create_chartsheet(\"Title\", index) to add the sheet, build the chart from a Reference to data on a worksheet, and attach it with chartsheet.add_chart(chart). A chartsheet holds exactly one chart.",[10,1921,1922,1925],{},[14,1923,1924],{},"Why does my openpyxl chartsheet look empty in LibreOffice?","\nopenpyxl writes the chart's size on a chartsheet as zero. Excel stretches the chart to fit the sheet anyway, but other applications draw it at its stored size. Set chart.anchor.ext to a real size after add_chart so every application shows it.",[10,1927,1928,1931,1932,1935],{},[14,1929,1930],{},"Can I read or write cells on a chartsheet?","\nNo. A chartsheet has no cells, so chartsheet",[182,1933,1934],{},"\"A1\""," raises a TypeError. Keep the data on a worksheet, and use wb.chartsheets to tell the two kinds of sheet apart when looping over a workbook.",[167,1937,1939],{"id":1938},"related","Related",[1829,1941,1942,1948,1953,1960],{},[1832,1943,1944,1945,1947],{},"Up one level: ",[19,1946,22],{"href":21}," — every chart type.",[1832,1949,1950,1952],{},[19,1951,1666],{"href":1665}," — chartsheets with xlsxwriter.",[1832,1954,1955,1959],{},[19,1956,1958],{"href":1957},"\u002Fgetting-started-with-python-excel-automation\u002Fusing-openpyxl-for-excel-file-manipulation\u002Fset-the-active-sheet-and-tab-colour-with-openpyxl\u002F","Set the Active Sheet and Tab Colour with openpyxl"," — tabs on worksheets.",[1832,1961,1962,1964],{},[19,1963,1822],{"href":1821}," — combining chart and data tabs.",[1966,1967,1968],"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 .s_Opv, html code.shiki .s_Opv{--shiki-default:#6F42C1;--shiki-dark:#DBB7FF}html pre.shiki code .sa561, html code.shiki .sa561{--shiki-default:#E36209;--shiki-dark:#FFB757}html pre.shiki code .sSjpA, html code.shiki .sSjpA{--shiki-default:#005CC5;--shiki-dark:#FF9492}",{"title":177,"searchDepth":238,"depth":238,"links":1970},[1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981],{"id":169,"depth":238,"text":170},{"id":201,"depth":238,"text":202},{"id":929,"depth":238,"text":930},{"id":1235,"depth":238,"text":1236},{"id":1493,"depth":238,"text":1494},{"id":1814,"depth":238,"text":1815},{"id":1826,"depth":238,"text":1827},{"id":1883,"depth":238,"text":1884},{"id":1890,"depth":238,"text":1891},{"id":1906,"depth":238,"text":1907},{"id":1938,"depth":238,"text":1939},"2026-09-25","Give a chart a whole sheet to itself — a full-screen, full-page chart tab that opens first in the workbook, prints on one page and cannot be dragged out of place. Create chartsheets with openpyxl, size the chart so every application shows it properly, make one per region in a loop, colour and order the tabs, protect them and set landscape printing.","md",[1986,1988,1990,1992],{"q":1912,"a":1987},"A sheet that holds a single chart and no cells. The chart fills the window, stays in place, and prints on a full page. Its data lives on an ordinary worksheet elsewhere in the workbook.",{"q":1918,"a":1989},"Call wb.create_chartsheet(\"Title\", index) to add the sheet, build the chart from a Reference to data on a worksheet, and attach it with chartsheet.add_chart(chart). A chartsheet holds exactly one chart.",{"q":1924,"a":1991},"openpyxl writes the chart's size on a chartsheet as zero. Excel stretches the chart to fit the sheet anyway, but other applications draw it at its stored size. Set chart.anchor.ext to a real size after add_chart so every application shows it.",{"q":1930,"a":1993},"No. A chartsheet has no cells, so chartsheet[\"A1\"] raises a TypeError. Keep the data on a worksheet, and use wb.chartsheets to tell the two kinds of sheet apart when looping over a workbook.","put a chart on its own chartsheet with openpyxl",null,{"breadcrumb":1997},[1998,2001,2004],{"name":1999,"item":2000},"Home","\u002F",{"name":2002,"item":2003},"Formatting and Charting Excel Reports with Python","\u002Fformatting-and-charting-excel-reports-with-python\u002F",{"name":22,"item":21},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl",{"title":2007,"description":2008},"Create an Excel Chartsheet (Full-Page Chart) with openpyxl","Put charts on dedicated chartsheets with openpyxl: create_chartsheet, add_chart, one chart per sheet, setting the absolute anchor size, a chartsheet per group, tab colours with ChartsheetProperties, ChartsheetProtection, landscape PrintPageSetup and the active sheet.","put-a-chart-on-its-own-chartsheet-with-openpyxl","formatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fput-a-chart-on-its-own-chartsheet-with-openpyxl\u002Findex",[2012,2013,2014],"charts-and-images","report-layouts","openpyxl","how-to","cXSjtx2kuv4_w9swDMvO7U2QjYKS3HvP8ZAnELe0ka4",[2018,2022],{"title":2019,"path":2020,"stem":2021,"children":-1},"Plot a Chart from Non-Adjacent Columns","\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fplot-a-chart-from-non-adjacent-columns","formatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fplot-a-chart-from-non-adjacent-columns\u002Findex",{"title":2023,"path":2024,"stem":2025,"children":-1},"Shade a Target Band Behind a Line Chart","\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fshade-a-target-band-behind-a-line-chart","formatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl\u002Fshade-a-target-band-behind-a-line-chart\u002Findex",[2027,2029],{"path":2028,"title":22},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fcreating-charts-in-excel-with-openpyxl",{"path":2030,"title":2002},"\u002Fformatting-and-charting-excel-reports-with-python",[],[2033,2036,2039,2042,2044,2047],{"path":2034,"title":2035,"kind":2015},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fbuild-a-dashboard-sheet-with-charts-from-multiple-tabs","Build a Dashboard Sheet with Charts from Multiple Tabs",{"path":2037,"title":2038,"kind":2015},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fbuild-a-rolling-12-month-chart-on-an-excel-dashboard","Build a Rolling 12-Month Chart on an Excel Dashboard",{"path":2040,"title":2041,"kind":2015},"\u002Fautomating-reporting-workflows\u002Fgenerating-excel-reports-from-templates\u002Fkeep-charts-and-images-when-filling-an-excel-template","Keep Charts and Images When Filling an Excel Template",{"path":2043,"title":1666,"kind":2015},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter\u002Fadd-a-chart-to-an-excel-file-with-xlsxwriter",{"path":2045,"title":2046,"kind":2015},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter\u002Fadd-sparklines-to-an-excel-report-with-xlsxwriter","Add Sparklines to an Excel Report with xlsxwriter",{"path":2048,"title":2049,"kind":2015},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fbuilding-excel-reports-with-xlsxwriter\u002Fbuild-a-waterfall-chart-in-excel-with-python","Build a Waterfall Chart in Excel with Python",1790972113317]