[{"data":1,"prerenderedAt":2210},["ShallowReactive",2],{"doc:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel":3,"surround:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel":2177,"ancestors:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel":2185,"children:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel":2190,"related:\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel":2191},{"id":4,"title":5,"body":6,"dateModified":2144,"datePublished":2144,"description":2145,"extension":2146,"faq":2147,"keyword":2156,"kind":2157,"meta":2158,"navigation":112,"path":2167,"seo":2168,"slug":2171,"stem":2172,"topics":2173,"type":2175,"__hash__":2176},"docs\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel\u002Findex.md","Show Zeros as Dashes or Hide Them in Excel",{"type":7,"value":8,"toc":2132},"minimark",[9,32,37,65,77,81,84,361,389,612,616,623,1211,1251,1360,1368,1392,1714,1724,1867,1871,1878,1978,1997,2001,2042,2046,2063,2067,2073,2079,2085,2095,2099,2128],[10,11,12,13,17,18,21,22,25,26,31],"p",{},"A financial report full of ",[14,15,16],"code",{},"0.00"," is hard to read: the figures that matter are lost among rows of zeros. Printed accounts solve this with a dash — \"–\" — in place of a zero, and some reports leave such cells empty altogether. Both are display choices, and Excel can make them without touching the underlying values, so totals and formulas keep working. The common shortcut in generated reports — writing an empty string or ",[14,19,20],{},"None"," instead of ",[14,23,24],{},"0"," — looks the same on screen but behaves differently: averages change, counts change, and formulas that do arithmetic on the cell can fail. This page shows zeros as dashes with a number format, hides them in chosen cells or a whole sheet, keeps the dashes aligned with the numbers around them, and checks with LibreOffice how each approach affects the calculations. It belongs to ",[27,28,30],"a",{"href":29},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002F","Applying Number and Date Formats in Excel",".",[33,34,36],"h2",{"id":35},"prerequisites","Prerequisites",[38,39,44],"pre",{"className":40,"code":41,"language":42,"meta":43,"style":43},"language-bash shiki shiki-themes github-light github-dark-high-contrast","pip install openpyxl pandas\n","bash","",[14,45,46],{"__ignoreMap":43},[47,48,51,55,59,62],"span",{"class":49,"line":50},"line",1,[47,52,54],{"class":53},"sMTad","pip",[47,56,58],{"class":57},"srMev"," install",[47,60,61],{"class":57}," openpyxl",[47,63,64],{"class":57}," pandas\n",[10,66,67,68,71,72,76],{},"LibreOffice (",[14,69,70],{},"soffice",") is used to recalculate the workbook and export what each cell ",[73,74,75],"em",{},"displays",", so the formats can be checked without opening Excel.",[33,78,80],{"id":79},"step-1-a-dash-from-the-zero-section","Step 1 — A dash from the zero section",[10,82,83],{},"A number format has up to four sections separated by semicolons: positive; negative; zero; text. Put a dash in the third and zeros display as a dash while staying zero:",[38,85,89],{"className":86,"code":87,"language":88,"meta":43,"style":43},"language-python shiki shiki-themes github-light github-dark-high-contrast","from openpyxl import Workbook\n\nDASH = '#,##0.00;-#,##0.00;\"–\"'\nDASH_ALIGNED = '#,##0.00_);(#,##0.00);\"–\"_)'\nHIDDEN = '#,##0.00;-#,##0.00;'\n\nwb = Workbook()\nws = wb.active\nws.title = \"Formats\"\nws.append([\"Value\", \"General\", \"Dash\", \"Dash, aligned\", \"Hidden\"])\nfor v in [1250.5, 0, -40, 0, 87.25]:\n    ws.append([v, v, v, v, v])\nfor row in ws.iter_rows(min_row=2):\n    row[2].number_format, row[3].number_format, row[4].number_format = DASH, DASH_ALIGNED, HIDDEN\nprint(DASH, \"|\", DASH_ALIGNED, \"|\", HIDDEN)\n","python",[14,90,91,107,114,127,138,149,154,166,177,188,221,263,269,294,330],{"__ignoreMap":43},[47,92,93,97,101,104],{"class":49,"line":50},[47,94,96],{"class":95},"s-kum","from",[47,98,100],{"class":99},"skGVy"," openpyxl ",[47,102,103],{"class":95},"import",[47,105,106],{"class":99}," Workbook\n",[47,108,110],{"class":49,"line":109},2,[47,111,113],{"emptyLinePlaceholder":112},true,"\n",[47,115,117,121,124],{"class":49,"line":116},3,[47,118,120],{"class":119},"sP0c6","DASH",[47,122,123],{"class":95}," =",[47,125,126],{"class":57}," '#,##0.00;-#,##0.00;\"–\"'\n",[47,128,130,133,135],{"class":49,"line":129},4,[47,131,132],{"class":119},"DASH_ALIGNED",[47,134,123],{"class":95},[47,136,137],{"class":57}," '#,##0.00_);(#,##0.00);\"–\"_)'\n",[47,139,141,144,146],{"class":49,"line":140},5,[47,142,143],{"class":119},"HIDDEN",[47,145,123],{"class":95},[47,147,148],{"class":57}," '#,##0.00;-#,##0.00;'\n",[47,150,152],{"class":49,"line":151},6,[47,153,113],{"emptyLinePlaceholder":112},[47,155,157,160,163],{"class":49,"line":156},7,[47,158,159],{"class":99},"wb ",[47,161,162],{"class":95},"=",[47,164,165],{"class":99}," Workbook()\n",[47,167,169,172,174],{"class":49,"line":168},8,[47,170,171],{"class":99},"ws ",[47,173,162],{"class":95},[47,175,176],{"class":99}," wb.active\n",[47,178,180,183,185],{"class":49,"line":179},9,[47,181,182],{"class":99},"ws.title ",[47,184,162],{"class":95},[47,186,187],{"class":57}," \"Formats\"\n",[47,189,191,194,197,200,203,205,208,210,213,215,218],{"class":49,"line":190},10,[47,192,193],{"class":99},"ws.append([",[47,195,196],{"class":57},"\"Value\"",[47,198,199],{"class":99},", ",[47,201,202],{"class":57},"\"General\"",[47,204,199],{"class":99},[47,206,207],{"class":57},"\"Dash\"",[47,209,199],{"class":99},[47,211,212],{"class":57},"\"Dash, aligned\"",[47,214,199],{"class":99},[47,216,217],{"class":57},"\"Hidden\"",[47,219,220],{"class":99},"])\n",[47,222,224,227,230,233,236,239,241,243,245,248,251,253,255,257,260],{"class":49,"line":223},11,[47,225,226],{"class":95},"for",[47,228,229],{"class":99}," v ",[47,231,232],{"class":95},"in",[47,234,235],{"class":99}," [",[47,237,238],{"class":119},"1250.5",[47,240,199],{"class":99},[47,242,24],{"class":119},[47,244,199],{"class":99},[47,246,247],{"class":95},"-",[47,249,250],{"class":119},"40",[47,252,199],{"class":99},[47,254,24],{"class":119},[47,256,199],{"class":99},[47,258,259],{"class":119},"87.25",[47,261,262],{"class":99},"]:\n",[47,264,266],{"class":49,"line":265},12,[47,267,268],{"class":99},"    ws.append([v, v, v, v, v])\n",[47,270,272,274,277,279,282,286,288,291],{"class":49,"line":271},13,[47,273,226],{"class":95},[47,275,276],{"class":99}," row ",[47,278,232],{"class":95},[47,280,281],{"class":99}," ws.iter_rows(",[47,283,285],{"class":284},"sa561","min_row",[47,287,162],{"class":95},[47,289,290],{"class":119},"2",[47,292,293],{"class":99},"):\n",[47,295,297,300,302,305,308,310,313,316,318,321,323,325,327],{"class":49,"line":296},14,[47,298,299],{"class":99},"    row[",[47,301,290],{"class":119},[47,303,304],{"class":99},"].number_format, row[",[47,306,307],{"class":119},"3",[47,309,304],{"class":99},[47,311,312],{"class":119},"4",[47,314,315],{"class":99},"].number_format ",[47,317,162],{"class":95},[47,319,320],{"class":119}," DASH",[47,322,199],{"class":99},[47,324,132],{"class":119},[47,326,199],{"class":99},[47,328,329],{"class":119},"HIDDEN\n",[47,331,333,336,339,341,343,346,348,350,352,354,356,358],{"class":49,"line":332},15,[47,334,335],{"class":119},"print",[47,337,338],{"class":99},"(",[47,340,120],{"class":119},[47,342,199],{"class":99},[47,344,345],{"class":57},"\"|\"",[47,347,199],{"class":99},[47,349,132],{"class":119},[47,351,199],{"class":99},[47,353,345],{"class":57},[47,355,199],{"class":99},[47,357,143],{"class":119},[47,359,360],{"class":99},")\n",[10,362,363,364,366,367,369,370,373,374,377,378,380,381,384,385,31],{},"In ",[14,365,120],{},", the third section is a quoted en dash, so a zero shows \"–\". ",[14,368,132],{}," follows the accounting convention of negatives in parentheses: ",[14,371,372],{},"_)"," inserts a space the width of a closing parenthesis after positive numbers and the dash, so that digits and dashes line up with negatives such as ",[14,375,376],{},"(40.00)"," above and below them. ",[14,379,143],{}," leaves the third section empty — the semicolon is there, but nothing after it — so a zero displays as nothing at all. A dash written with ",[14,382,383],{},"\"-\""," instead of the en dash works too; the en dash is simply the typographic convention in financial statements. The section syntax is explained further in ",[27,386,388],{"href":387},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fwrite-custom-number-format-codes-in-excel-with-python\u002F","Write Custom Number Format Codes in Excel with Python",[390,391,399,400,399,404,399,408,399,415,399,424,399,428,399,435,399,439,399,443,399,447,399,451,399,454,399,458,399,462,399,467,399,472,399,476,399,478,399,481,399,483,399,486,399,488,399,491,399,494,399,497,399,499,399,502,399,504,399,507,399,509,399,512,399,514,399,516,399,519,399,522,399,524,399,526,399,530,399,534,399,536,399,539,399,543,399,546,399,549,399,551,399,554,399,556,399,559,399,561,399,563,399,565,399,567,399,570,399,574,399,576,399,578,399,580,399,582,399,584,399,586,399,588,399,591,399,595,399,597,399,599,399,601,399,603,399,605,399,608,399,610],"svg",{"viewBox":392,"role":393,"ariaLabelledBy":394,"xmlns":397,"style":398},"182 0 395 224","img",[395,396],"zd-display-t","zd-display-d","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;max-width:395px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif","\n  ",[401,402,403],"title",{"id":395},"The same values under three formats",[405,406,407],"desc",{"id":396},"The values 1,250.50, 0, minus 40, 0 and 87.25. With the dash format zeros show as an en dash. With the aligned format negatives show in parentheses and positives and dashes leave room for the parenthesis. With the hidden format zeros show nothing.",[409,410],"rect",{"x":411,"y":24,"width":412,"height":413,"fill":414},"182","395","224","#ffffff",[409,416],{"x":417,"y":418,"width":419,"height":420,"rx":24,"fill":421,"stroke":422,"style":423},"198.7","16.0","32.0","24.0","#e7ebef","var(--line,#cdd5e6)","stroke-width:1px",[409,425],{"x":426,"y":418,"width":427,"height":420,"rx":24,"fill":421,"stroke":422,"style":423},"230.7","65.7",[429,430,434],"text",{"x":431,"y":432,"style":433},"263.6","33.0","font-size:11px;font-weight:600;fill:var(--muted,#5b6780);text-anchor:middle","A",[409,436],{"x":437,"y":418,"width":438,"height":420,"rx":24,"fill":421,"stroke":422,"style":423},"296.5","78.4",[429,440,442],{"x":441,"y":432,"style":433},"335.7","B",[409,444],{"x":445,"y":418,"width":446,"height":420,"rx":24,"fill":421,"stroke":422,"style":423},"374.9","107.9",[429,448,450],{"x":449,"y":432,"style":433},"428.9","C",[409,452],{"x":453,"y":418,"width":438,"height":420,"rx":24,"fill":421,"stroke":422,"style":423},"482.8",[429,455,457],{"x":456,"y":432,"style":433},"522.1","D",[409,459],{"x":417,"y":460,"width":419,"height":461,"rx":24,"fill":421,"stroke":422,"style":423},"40.0","28.0",[429,463,466],{"x":464,"y":465,"style":433},"214.7","59.0","1",[409,468],{"x":426,"y":460,"width":427,"height":461,"rx":24,"fill":469,"stroke":470,"style":471},"#f0f4ff","var(--brand,#5b5cf0)","stroke-width:1.5px",[429,473,475],{"x":431,"y":465,"style":474},"font-size:12px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","Value",[409,477],{"x":437,"y":460,"width":438,"height":461,"rx":24,"fill":469,"stroke":470,"style":471},[429,479,480],{"x":441,"y":465,"style":474},"Dash",[409,482],{"x":445,"y":460,"width":446,"height":461,"rx":24,"fill":469,"stroke":470,"style":471},[429,484,485],{"x":449,"y":465,"style":474},"Dash, aligned",[409,487],{"x":453,"y":460,"width":438,"height":461,"rx":24,"fill":469,"stroke":470,"style":471},[429,489,490],{"x":456,"y":465,"style":474},"Hidden",[409,492],{"x":417,"y":493,"width":419,"height":461,"rx":24,"fill":421,"stroke":422,"style":423},"68.0",[429,495,290],{"x":464,"y":496,"style":433},"87.0",[409,498],{"x":426,"y":493,"width":427,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,500,238],{"x":431,"y":496,"style":501},"font-size:12px;font-weight:400;fill:var(--text,#172033);text-anchor:middle",[409,503],{"x":437,"y":493,"width":438,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,505,506],{"x":441,"y":496,"style":501},"1,250.50",[409,508],{"x":445,"y":493,"width":446,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,510,511],{"x":449,"y":496,"style":501},"1,250.50 ",[409,513],{"x":453,"y":493,"width":438,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,515,506],{"x":456,"y":496,"style":501},[409,517],{"x":417,"y":518,"width":419,"height":461,"rx":24,"fill":421,"stroke":422,"style":423},"96.0",[429,520,307],{"x":464,"y":521,"style":433},"115.0",[409,523],{"x":426,"y":518,"width":427,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,525,24],{"x":431,"y":521,"style":501},[409,527],{"x":437,"y":518,"width":438,"height":461,"rx":24,"fill":528,"stroke":529,"style":471},"#d9f4f1","var(--teal,#0f9488)",[429,531,533],{"x":441,"y":521,"style":532},"font-size:12px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","–",[409,535],{"x":445,"y":518,"width":446,"height":461,"rx":24,"fill":528,"stroke":529,"style":471},[429,537,538],{"x":449,"y":521,"style":532},"– ",[409,540],{"x":453,"y":518,"width":438,"height":461,"rx":24,"fill":541,"stroke":542,"style":471},"#fdefd8","var(--gold,#b4740a)",[409,544],{"x":417,"y":545,"width":419,"height":461,"rx":24,"fill":421,"stroke":422,"style":423},"124.0",[429,547,312],{"x":464,"y":548,"style":433},"143.0",[409,550],{"x":426,"y":545,"width":427,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,552,553],{"x":431,"y":548,"style":501},"-40",[409,555],{"x":437,"y":545,"width":438,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,557,558],{"x":441,"y":548,"style":501},"-40.00",[409,560],{"x":445,"y":545,"width":446,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,562,376],{"x":449,"y":548,"style":501},[409,564],{"x":453,"y":545,"width":438,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,566,558],{"x":456,"y":548,"style":501},[409,568],{"x":417,"y":569,"width":419,"height":461,"rx":24,"fill":421,"stroke":422,"style":423},"152.0",[429,571,573],{"x":464,"y":572,"style":433},"171.0","5",[409,575],{"x":426,"y":569,"width":427,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,577,24],{"x":431,"y":572,"style":501},[409,579],{"x":437,"y":569,"width":438,"height":461,"rx":24,"fill":528,"stroke":529,"style":471},[429,581,533],{"x":441,"y":572,"style":532},[409,583],{"x":445,"y":569,"width":446,"height":461,"rx":24,"fill":528,"stroke":529,"style":471},[429,585,538],{"x":449,"y":572,"style":532},[409,587],{"x":453,"y":569,"width":438,"height":461,"rx":24,"fill":541,"stroke":542,"style":471},[409,589],{"x":417,"y":590,"width":419,"height":461,"rx":24,"fill":421,"stroke":422,"style":423},"180.0",[429,592,594],{"x":464,"y":593,"style":433},"199.0","6",[409,596],{"x":426,"y":590,"width":427,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,598,259],{"x":431,"y":593,"style":501},[409,600],{"x":437,"y":590,"width":438,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,602,259],{"x":441,"y":593,"style":501},[409,604],{"x":445,"y":590,"width":446,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,606,607],{"x":449,"y":593,"style":501},"87.25 ",[409,609],{"x":453,"y":590,"width":438,"height":461,"rx":24,"fill":414,"stroke":422,"style":423},[429,611,259],{"x":456,"y":593,"style":501},[33,613,615],{"id":614},"step-2-hidden-zero-empty-string-or-true-blank","Step 2 — Hidden zero, empty string or true blank?",[10,617,618,619,622],{},"There are three ways to make a cell ",[73,620,621],{},"look"," empty, and they are not equivalent. Build a column of each, add formulas over them, and let LibreOffice calculate:",[38,624,626],{"className":86,"code":625,"language":88,"meta":43,"style":43},"ws2 = wb.create_sheet(\"Behaviour\")\nws2.append([\"Zero, hidden by format\", 'Formula returning \"\"', \"Blank (None)\"])\nfor v in [100, 0, 50]:\n    ws2.append([v, v if v else '=\"\"', v if v else None])\nfor c in ws2[\"A\"][1:]:\n    c.number_format = HIDDEN\nlabels = [\"SUM\", \"AVERAGE\", \"COUNT\", \"COUNTA\", \"Cell + 1\"]\nformulas = [\"=SUM({c}2:{c}4)\", \"=AVERAGE({c}2:{c}4)\", \"=COUNT({c}2:{c}4)\", \"=COUNTA({c}2:{c}4)\", \"={c}3+1\"]\nfor r, (label, f) in enumerate(zip(labels, formulas), start=6):\n    ws2[f\"D{r}\"] = label\n    for col in \"ABC\":\n        ws2[f\"{col}{r}\"] = f.format(c=col)\nwb.save(\"zeros.xlsx\")\n\nimport csv, subprocess\nAS_SHOWN = \"csv:Text - txt - csv (StarCalc):44,34,76,1,,0,false,true,true,false,false,-1\"\nsubprocess.run([\"soffice\", \"--headless\", \"--convert-to\", AS_SHOWN, \"--outdir\", \"calc\", \"zeros.xlsx\"], check=True, capture_output=True)\nfor name in [\"Formats\", \"Behaviour\"]:\n    print(f\"--- {name}\")\n    with open(f\"calc\u002Fzeros-{name}.csv\", encoding=\"utf-8\") as f:\n        for row in csv.reader(f):\n            print(\" | \".join(f\"{c:>12}\" for c in row[:5]))\n",[14,627,628,643,663,687,717,740,750,785,860,889,920,936,974,984,988,995,1006,1065,1086,1110,1154,1167],{"__ignoreMap":43},[47,629,630,633,635,638,641],{"class":49,"line":50},[47,631,632],{"class":99},"ws2 ",[47,634,162],{"class":95},[47,636,637],{"class":99}," wb.create_sheet(",[47,639,640],{"class":57},"\"Behaviour\"",[47,642,360],{"class":99},[47,644,645,648,651,653,656,658,661],{"class":49,"line":109},[47,646,647],{"class":99},"ws2.append([",[47,649,650],{"class":57},"\"Zero, hidden by format\"",[47,652,199],{"class":99},[47,654,655],{"class":57},"'Formula returning \"\"'",[47,657,199],{"class":99},[47,659,660],{"class":57},"\"Blank (None)\"",[47,662,220],{"class":99},[47,664,665,667,669,671,673,676,678,680,682,685],{"class":49,"line":116},[47,666,226],{"class":95},[47,668,229],{"class":99},[47,670,232],{"class":95},[47,672,235],{"class":99},[47,674,675],{"class":119},"100",[47,677,199],{"class":99},[47,679,24],{"class":119},[47,681,199],{"class":99},[47,683,684],{"class":119},"50",[47,686,262],{"class":99},[47,688,689,692,695,697,700,703,706,708,710,712,715],{"class":49,"line":129},[47,690,691],{"class":99},"    ws2.append([v, v ",[47,693,694],{"class":95},"if",[47,696,229],{"class":99},[47,698,699],{"class":95},"else",[47,701,702],{"class":57}," '=\"\"'",[47,704,705],{"class":99},", v ",[47,707,694],{"class":95},[47,709,229],{"class":99},[47,711,699],{"class":95},[47,713,714],{"class":119}," None",[47,716,220],{"class":99},[47,718,719,721,724,726,729,732,735,737],{"class":49,"line":140},[47,720,226],{"class":95},[47,722,723],{"class":99}," c ",[47,725,232],{"class":95},[47,727,728],{"class":99}," ws2[",[47,730,731],{"class":57},"\"A\"",[47,733,734],{"class":99},"][",[47,736,466],{"class":119},[47,738,739],{"class":99},":]:\n",[47,741,742,745,747],{"class":49,"line":151},[47,743,744],{"class":99},"    c.number_format ",[47,746,162],{"class":95},[47,748,749],{"class":119}," HIDDEN\n",[47,751,752,755,757,759,762,764,767,769,772,774,777,779,782],{"class":49,"line":156},[47,753,754],{"class":99},"labels ",[47,756,162],{"class":95},[47,758,235],{"class":99},[47,760,761],{"class":57},"\"SUM\"",[47,763,199],{"class":99},[47,765,766],{"class":57},"\"AVERAGE\"",[47,768,199],{"class":99},[47,770,771],{"class":57},"\"COUNT\"",[47,773,199],{"class":99},[47,775,776],{"class":57},"\"COUNTA\"",[47,778,199],{"class":99},[47,780,781],{"class":57},"\"Cell + 1\"",[47,783,784],{"class":99},"]\n",[47,786,787,790,792,794,797,801,804,806,809,811,814,816,818,820,822,824,827,829,831,833,835,837,840,842,844,846,848,850,853,855,858],{"class":49,"line":168},[47,788,789],{"class":99},"formulas ",[47,791,162],{"class":95},[47,793,235],{"class":99},[47,795,796],{"class":57},"\"=SUM(",[47,798,800],{"class":799},"sSjpA","{c}",[47,802,803],{"class":57},"2:",[47,805,800],{"class":799},[47,807,808],{"class":57},"4)\"",[47,810,199],{"class":99},[47,812,813],{"class":57},"\"=AVERAGE(",[47,815,800],{"class":799},[47,817,803],{"class":57},[47,819,800],{"class":799},[47,821,808],{"class":57},[47,823,199],{"class":99},[47,825,826],{"class":57},"\"=COUNT(",[47,828,800],{"class":799},[47,830,803],{"class":57},[47,832,800],{"class":799},[47,834,808],{"class":57},[47,836,199],{"class":99},[47,838,839],{"class":57},"\"=COUNTA(",[47,841,800],{"class":799},[47,843,803],{"class":57},[47,845,800],{"class":799},[47,847,808],{"class":57},[47,849,199],{"class":99},[47,851,852],{"class":57},"\"=",[47,854,800],{"class":799},[47,856,857],{"class":57},"3+1\"",[47,859,784],{"class":99},[47,861,862,864,867,869,872,874,877,880,883,885,887],{"class":49,"line":179},[47,863,226],{"class":95},[47,865,866],{"class":99}," r, (label, f) ",[47,868,232],{"class":95},[47,870,871],{"class":119}," enumerate",[47,873,338],{"class":99},[47,875,876],{"class":119},"zip",[47,878,879],{"class":99},"(labels, formulas), ",[47,881,882],{"class":284},"start",[47,884,162],{"class":95},[47,886,594],{"class":119},[47,888,293],{"class":99},[47,890,891,894,897,900,903,906,909,912,915,917],{"class":49,"line":190},[47,892,893],{"class":99},"    ws2[",[47,895,896],{"class":95},"f",[47,898,899],{"class":57},"\"D",[47,901,902],{"class":799},"{",[47,904,905],{"class":99},"r",[47,907,908],{"class":799},"}",[47,910,911],{"class":57},"\"",[47,913,914],{"class":99},"] ",[47,916,162],{"class":95},[47,918,919],{"class":99}," label\n",[47,921,922,925,928,930,933],{"class":49,"line":223},[47,923,924],{"class":95},"    for",[47,926,927],{"class":99}," col ",[47,929,232],{"class":95},[47,931,932],{"class":57}," \"ABC\"",[47,934,935],{"class":99},":\n",[47,937,938,941,943,945,947,950,953,955,957,959,961,963,966,969,971],{"class":49,"line":265},[47,939,940],{"class":99},"        ws2[",[47,942,896],{"class":95},[47,944,911],{"class":57},[47,946,902],{"class":799},[47,948,949],{"class":99},"col",[47,951,952],{"class":799},"}{",[47,954,905],{"class":99},[47,956,908],{"class":799},[47,958,911],{"class":57},[47,960,914],{"class":99},[47,962,162],{"class":95},[47,964,965],{"class":99}," f.format(",[47,967,968],{"class":284},"c",[47,970,162],{"class":95},[47,972,973],{"class":99},"col)\n",[47,975,976,979,982],{"class":49,"line":271},[47,977,978],{"class":99},"wb.save(",[47,980,981],{"class":57},"\"zeros.xlsx\"",[47,983,360],{"class":99},[47,985,986],{"class":49,"line":296},[47,987,113],{"emptyLinePlaceholder":112},[47,989,990,992],{"class":49,"line":332},[47,991,103],{"class":95},[47,993,994],{"class":99}," csv, subprocess\n",[47,996,998,1001,1003],{"class":49,"line":997},16,[47,999,1000],{"class":119},"AS_SHOWN",[47,1002,123],{"class":95},[47,1004,1005],{"class":57}," \"csv:Text - txt - csv (StarCalc):44,34,76,1,,0,false,true,true,false,false,-1\"\n",[47,1007,1009,1012,1015,1017,1020,1022,1025,1027,1029,1031,1034,1036,1039,1041,1043,1046,1049,1051,1054,1056,1059,1061,1063],{"class":49,"line":1008},17,[47,1010,1011],{"class":99},"subprocess.run([",[47,1013,1014],{"class":57},"\"soffice\"",[47,1016,199],{"class":99},[47,1018,1019],{"class":57},"\"--headless\"",[47,1021,199],{"class":99},[47,1023,1024],{"class":57},"\"--convert-to\"",[47,1026,199],{"class":99},[47,1028,1000],{"class":119},[47,1030,199],{"class":99},[47,1032,1033],{"class":57},"\"--outdir\"",[47,1035,199],{"class":99},[47,1037,1038],{"class":57},"\"calc\"",[47,1040,199],{"class":99},[47,1042,981],{"class":57},[47,1044,1045],{"class":99},"], ",[47,1047,1048],{"class":284},"check",[47,1050,162],{"class":95},[47,1052,1053],{"class":119},"True",[47,1055,199],{"class":99},[47,1057,1058],{"class":284},"capture_output",[47,1060,162],{"class":95},[47,1062,1053],{"class":119},[47,1064,360],{"class":99},[47,1066,1068,1070,1073,1075,1077,1080,1082,1084],{"class":49,"line":1067},18,[47,1069,226],{"class":95},[47,1071,1072],{"class":99}," name ",[47,1074,232],{"class":95},[47,1076,235],{"class":99},[47,1078,1079],{"class":57},"\"Formats\"",[47,1081,199],{"class":99},[47,1083,640],{"class":57},[47,1085,262],{"class":99},[47,1087,1089,1092,1094,1096,1099,1101,1104,1106,1108],{"class":49,"line":1088},19,[47,1090,1091],{"class":119},"    print",[47,1093,338],{"class":99},[47,1095,896],{"class":95},[47,1097,1098],{"class":57},"\"--- ",[47,1100,902],{"class":799},[47,1102,1103],{"class":99},"name",[47,1105,908],{"class":799},[47,1107,911],{"class":57},[47,1109,360],{"class":99},[47,1111,1113,1116,1119,1121,1123,1126,1128,1130,1132,1135,1137,1140,1142,1145,1148,1151],{"class":49,"line":1112},20,[47,1114,1115],{"class":95},"    with",[47,1117,1118],{"class":119}," open",[47,1120,338],{"class":99},[47,1122,896],{"class":95},[47,1124,1125],{"class":57},"\"calc\u002Fzeros-",[47,1127,902],{"class":799},[47,1129,1103],{"class":99},[47,1131,908],{"class":799},[47,1133,1134],{"class":57},".csv\"",[47,1136,199],{"class":99},[47,1138,1139],{"class":284},"encoding",[47,1141,162],{"class":95},[47,1143,1144],{"class":57},"\"utf-8\"",[47,1146,1147],{"class":99},") ",[47,1149,1150],{"class":95},"as",[47,1152,1153],{"class":99}," f:\n",[47,1155,1157,1160,1162,1164],{"class":49,"line":1156},21,[47,1158,1159],{"class":95},"        for",[47,1161,276],{"class":99},[47,1163,232],{"class":95},[47,1165,1166],{"class":99}," csv.reader(f):\n",[47,1168,1170,1173,1175,1178,1181,1183,1185,1187,1189,1192,1194,1196,1199,1201,1203,1206,1208],{"class":49,"line":1169},22,[47,1171,1172],{"class":119},"            print",[47,1174,338],{"class":99},[47,1176,1177],{"class":57},"\" | \"",[47,1179,1180],{"class":99},".join(",[47,1182,896],{"class":95},[47,1184,911],{"class":57},[47,1186,902],{"class":799},[47,1188,968],{"class":99},[47,1190,1191],{"class":95},":>12",[47,1193,908],{"class":799},[47,1195,911],{"class":57},[47,1197,1198],{"class":95}," for",[47,1200,723],{"class":99},[47,1202,232],{"class":95},[47,1204,1205],{"class":99}," row[:",[47,1207,573],{"class":119},[47,1209,1210],{"class":99},"]))\n",[10,1212,1213,1214,1217,1218,1221,1222,1225,1226,1229,1230,1233,1234,1236,1237,1240,1241,1244,1245,1247,1248,1250],{},"The ",[14,1215,1216],{},"-1"," at the end of the filter options exports every sheet to its own CSV file, with each cell as displayed. On the ",[73,1219,1220],{},"Formats"," sheet the dashes and hidden zeros appear exactly as designed. On the ",[73,1223,1224],{},"Behaviour"," sheet the three columns look identical — 100, nothing, 50 — but calculate differently. The hidden zero is still a number: SUM is 150, AVERAGE is 50 because it divides by three, COUNT is 3, and adding 1 to it gives 1. The formula returning ",[14,1227,1228],{},"\"\""," — the familiar ",[14,1231,1232],{},"=IF(A2=0,\"\",A2)"," pattern — produces ",[73,1235,429],{},": SUM ignores it, but AVERAGE becomes 75 because it only averages two numbers, COUNT drops to 2, COUNTA still counts it, and ",[14,1238,1239],{},"cell + 1"," fails with ",[14,1242,1243],{},"#VALUE!",". The true blank behaves like the empty text for SUM, AVERAGE and COUNT, but is not counted by COUNTA, and ",[14,1246,1239],{}," treats it as zero. Note that writing the Python value ",[14,1249,1228],{}," with openpyxl is not the same as the formula: openpyxl stores it as a string cell with no content, which LibreOffice reads as a blank — one more reason not to rely on empty strings to mean anything.",[390,1252,399,1258,399,1261,399,1264,399,1268,399,1272,399,1277,399,1283,399,1286,399,1290,399,1293,399,1297,399,1301,399,1306,399,1308,399,1312,399,1314,399,1316,399,1318,399,1320,399,1323,399,1327,399,1329,399,1333,399,1335,399,1337,399,1339,399,1341,399,1343,399,1347,399,1349,399,1352,399,1354,399,1356,399,1358],{"viewBox":1253,"role":393,"ariaLabelledBy":1254,"xmlns":397,"style":1257},"4 0 752 174",[1255,1256],"zd-behaviour-t","zd-behaviour-d","width:100%;max-width:752px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif",[401,1259,1260],{"id":1255},"Three cells that look empty, calculated",[405,1262,1263],{"id":1256},"A zero hidden by its number format is still counted by AVERAGE and COUNT and works in arithmetic. Empty text from a formula is skipped by AVERAGE and COUNT, counted by COUNTA, and breaks arithmetic with VALUE errors. A true blank is skipped by AVERAGE, COUNT and COUNTA and counts as zero in arithmetic.",[409,1265],{"x":312,"y":24,"width":1266,"height":1267,"fill":414},"752","174",[409,1269],{"x":1270,"y":418,"width":1271,"height":460,"rx":24,"fill":414,"stroke":422,"style":423},"20.0","158.4",[409,1273],{"x":1274,"y":418,"width":1275,"height":460,"rx":24,"fill":469,"stroke":470,"style":1276},"178.4","187.2","stroke-width:1.2px",[429,1278,1282],{"x":1279,"y":1280,"style":1281},"272.0","41.0","font-size:13px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","AVERAGE(100, x, 50)",[409,1284],{"x":1285,"y":418,"width":1275,"height":460,"rx":24,"fill":469,"stroke":470,"style":1276},"365.6",[429,1287,1289],{"x":1288,"y":1280,"style":1281},"459.2","COUNT",[409,1291],{"x":1292,"y":418,"width":1275,"height":460,"rx":24,"fill":469,"stroke":470,"style":1276},"552.8",[429,1294,1296],{"x":1295,"y":1280,"style":1281},"646.4","x + 1",[409,1298],{"x":1270,"y":1299,"width":1271,"height":1300,"rx":24,"fill":421,"stroke":422,"style":423},"56.0","34.0",[429,1302,1305],{"x":419,"y":1303,"style":1304},"78.0","font-size:12.5px;font-weight:700;fill:var(--text,#172033);text-anchor:start","0, hidden by format",[409,1307],{"x":1274,"y":1299,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1309,684],{"x":1279,"y":1310,"style":1311},"77.0","font-size:11.5px;font-weight:400;fill:var(--text,#172033);text-anchor:middle",[409,1313],{"x":1285,"y":1299,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1315,307],{"x":1288,"y":1310,"style":1311},[409,1317],{"x":1292,"y":1299,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1319,466],{"x":1295,"y":1310,"style":1311},[409,1321],{"x":1270,"y":1322,"width":1271,"height":1300,"rx":24,"fill":421,"stroke":422,"style":423},"90.0",[429,1324,1326],{"x":419,"y":1325,"style":1304},"112.0","formula returning \"\"",[409,1328],{"x":1274,"y":1322,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1330,1332],{"x":1279,"y":1331,"style":1311},"111.0","75",[409,1334],{"x":1285,"y":1322,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1336,290],{"x":1288,"y":1331,"style":1311},[409,1338],{"x":1292,"y":1322,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1340,1243],{"x":1295,"y":1331,"style":1311},[409,1342],{"x":1270,"y":545,"width":1271,"height":1300,"rx":24,"fill":421,"stroke":422,"style":423},[429,1344,1346],{"x":419,"y":1345,"style":1304},"146.0","blank (None)",[409,1348],{"x":1274,"y":545,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1350,1332],{"x":1279,"y":1351,"style":1311},"145.0",[409,1353],{"x":1285,"y":545,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1355,290],{"x":1288,"y":1351,"style":1311},[409,1357],{"x":1292,"y":545,"width":1275,"height":1300,"rx":24,"fill":414,"stroke":422,"style":423},[429,1359,466],{"x":1295,"y":1351,"style":1311},[33,1361,1363,1364,1367],{"id":1362},"step-3-choose-what-the-cell-should-be-then-how-it-looks","Step 3 — Choose what the cell should ",[73,1365,1366],{},"be",", then how it looks",[10,1369,1370,1371,1373,1374,1377,1378,1380,1381,1383,1384,1387,1388,1391],{},"The table makes the rule clear. If the value is genuinely zero — no sales of a product this month, a cost line that was nil — write ",[14,1372,24],{}," and use a number format to show a dash or nothing; averages and counts then include it, as they should. If the value is ",[73,1375,1376],{},"missing"," — no data, not applicable — write a true blank, so averages and counts leave it out. Never use empty text — a ",[14,1379,1228],{}," value or a formula returning ",[14,1382,1228],{}," — to stand for zero in a numeric column. From pandas this means keeping zeros as zeros and missing values as ",[14,1385,1386],{},"NaN",", which ",[14,1389,1390],{},"to_excel"," writes as true blanks:",[38,1393,1395],{"className":86,"code":1394,"language":88,"meta":43,"style":43},"import pandas as pd\nfrom openpyxl import load_workbook\n\ndf = pd.DataFrame({\"Product\": [\"Bolts\", \"Nuts\", \"Washers\", \"Rivets\"],\n                   \"Jul\": [1200.0, 0.0, 310.0, None], \"Aug\": [980.0, 0.0, 0.0, 150.0], \"Sep\": [1105.5, 45.0, 0.0, 0.0]})\ndf.to_excel(\"sales_q3.xlsx\", index=False)\nwb = load_workbook(\"sales_q3.xlsx\")\nws = wb.active\nfor row in ws.iter_rows(min_row=2, min_col=2):\n    for cell in row:\n        cell.number_format = DASH_ALIGNED\nwb.save(\"sales_q3.xlsx\")\nsubprocess.run([\"soffice\", \"--headless\", \"--convert-to\", AS_SHOWN, \"--outdir\", \"calc\", \"sales_q3.xlsx\"], check=True, capture_output=True)\nfrom pathlib import Path\nprint(Path(\"calc\u002Fsales_q3-Sheet1.csv\").read_text(encoding=\"utf-8\"))\n",[14,1396,1397,1409,1420,1424,1461,1534,1554,1567,1575,1602,1614,1624,1632,1680,1692],{"__ignoreMap":43},[47,1398,1399,1401,1404,1406],{"class":49,"line":50},[47,1400,103],{"class":95},[47,1402,1403],{"class":99}," pandas ",[47,1405,1150],{"class":95},[47,1407,1408],{"class":99}," pd\n",[47,1410,1411,1413,1415,1417],{"class":49,"line":109},[47,1412,96],{"class":95},[47,1414,100],{"class":99},[47,1416,103],{"class":95},[47,1418,1419],{"class":99}," load_workbook\n",[47,1421,1422],{"class":49,"line":116},[47,1423,113],{"emptyLinePlaceholder":112},[47,1425,1426,1429,1431,1434,1437,1440,1443,1445,1448,1450,1453,1455,1458],{"class":49,"line":129},[47,1427,1428],{"class":99},"df ",[47,1430,162],{"class":95},[47,1432,1433],{"class":99}," pd.DataFrame({",[47,1435,1436],{"class":57},"\"Product\"",[47,1438,1439],{"class":99},": [",[47,1441,1442],{"class":57},"\"Bolts\"",[47,1444,199],{"class":99},[47,1446,1447],{"class":57},"\"Nuts\"",[47,1449,199],{"class":99},[47,1451,1452],{"class":57},"\"Washers\"",[47,1454,199],{"class":99},[47,1456,1457],{"class":57},"\"Rivets\"",[47,1459,1460],{"class":99},"],\n",[47,1462,1463,1466,1468,1471,1473,1476,1478,1481,1483,1485,1487,1490,1492,1495,1497,1499,1501,1503,1505,1508,1510,1513,1515,1518,1520,1523,1525,1527,1529,1531],{"class":49,"line":140},[47,1464,1465],{"class":57},"                   \"Jul\"",[47,1467,1439],{"class":99},[47,1469,1470],{"class":119},"1200.0",[47,1472,199],{"class":99},[47,1474,1475],{"class":119},"0.0",[47,1477,199],{"class":99},[47,1479,1480],{"class":119},"310.0",[47,1482,199],{"class":99},[47,1484,20],{"class":119},[47,1486,1045],{"class":99},[47,1488,1489],{"class":57},"\"Aug\"",[47,1491,1439],{"class":99},[47,1493,1494],{"class":119},"980.0",[47,1496,199],{"class":99},[47,1498,1475],{"class":119},[47,1500,199],{"class":99},[47,1502,1475],{"class":119},[47,1504,199],{"class":99},[47,1506,1507],{"class":119},"150.0",[47,1509,1045],{"class":99},[47,1511,1512],{"class":57},"\"Sep\"",[47,1514,1439],{"class":99},[47,1516,1517],{"class":119},"1105.5",[47,1519,199],{"class":99},[47,1521,1522],{"class":119},"45.0",[47,1524,199],{"class":99},[47,1526,1475],{"class":119},[47,1528,199],{"class":99},[47,1530,1475],{"class":119},[47,1532,1533],{"class":99},"]})\n",[47,1535,1536,1539,1542,1544,1547,1549,1552],{"class":49,"line":151},[47,1537,1538],{"class":99},"df.to_excel(",[47,1540,1541],{"class":57},"\"sales_q3.xlsx\"",[47,1543,199],{"class":99},[47,1545,1546],{"class":284},"index",[47,1548,162],{"class":95},[47,1550,1551],{"class":119},"False",[47,1553,360],{"class":99},[47,1555,1556,1558,1560,1563,1565],{"class":49,"line":156},[47,1557,159],{"class":99},[47,1559,162],{"class":95},[47,1561,1562],{"class":99}," load_workbook(",[47,1564,1541],{"class":57},[47,1566,360],{"class":99},[47,1568,1569,1571,1573],{"class":49,"line":168},[47,1570,171],{"class":99},[47,1572,162],{"class":95},[47,1574,176],{"class":99},[47,1576,1577,1579,1581,1583,1585,1587,1589,1591,1593,1596,1598,1600],{"class":49,"line":179},[47,1578,226],{"class":95},[47,1580,276],{"class":99},[47,1582,232],{"class":95},[47,1584,281],{"class":99},[47,1586,285],{"class":284},[47,1588,162],{"class":95},[47,1590,290],{"class":119},[47,1592,199],{"class":99},[47,1594,1595],{"class":284},"min_col",[47,1597,162],{"class":95},[47,1599,290],{"class":119},[47,1601,293],{"class":99},[47,1603,1604,1606,1609,1611],{"class":49,"line":190},[47,1605,924],{"class":95},[47,1607,1608],{"class":99}," cell ",[47,1610,232],{"class":95},[47,1612,1613],{"class":99}," row:\n",[47,1615,1616,1619,1621],{"class":49,"line":223},[47,1617,1618],{"class":99},"        cell.number_format ",[47,1620,162],{"class":95},[47,1622,1623],{"class":119}," DASH_ALIGNED\n",[47,1625,1626,1628,1630],{"class":49,"line":265},[47,1627,978],{"class":99},[47,1629,1541],{"class":57},[47,1631,360],{"class":99},[47,1633,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678],{"class":49,"line":271},[47,1635,1011],{"class":99},[47,1637,1014],{"class":57},[47,1639,199],{"class":99},[47,1641,1019],{"class":57},[47,1643,199],{"class":99},[47,1645,1024],{"class":57},[47,1647,199],{"class":99},[47,1649,1000],{"class":119},[47,1651,199],{"class":99},[47,1653,1033],{"class":57},[47,1655,199],{"class":99},[47,1657,1038],{"class":57},[47,1659,199],{"class":99},[47,1661,1541],{"class":57},[47,1663,1045],{"class":99},[47,1665,1048],{"class":284},[47,1667,162],{"class":95},[47,1669,1053],{"class":119},[47,1671,199],{"class":99},[47,1673,1058],{"class":284},[47,1675,162],{"class":95},[47,1677,1053],{"class":119},[47,1679,360],{"class":99},[47,1681,1682,1684,1687,1689],{"class":49,"line":296},[47,1683,96],{"class":95},[47,1685,1686],{"class":99}," pathlib ",[47,1688,103],{"class":95},[47,1690,1691],{"class":99}," Path\n",[47,1693,1694,1696,1699,1702,1705,1707,1709,1711],{"class":49,"line":332},[47,1695,335],{"class":119},[47,1697,1698],{"class":99},"(Path(",[47,1700,1701],{"class":57},"\"calc\u002Fsales_q3-Sheet1.csv\"",[47,1703,1704],{"class":99},").read_text(",[47,1706,1139],{"class":284},[47,1708,162],{"class":95},[47,1710,1144],{"class":57},[47,1712,1713],{"class":99},"))\n",[10,1715,1716,1717,1719,1720,31],{},"The zeros now read as aligned dashes — Nuts in July and August, Washers in August and September — while Rivets' July, missing rather than zero, stays empty. A reader can tell the difference between \"nothing sold\" and \"no data\", which a sheet of blanks or a sheet of zeros would hide. How pandas writes ",[14,1718,1386],{}," and infinity in general is covered in ",[27,1721,1723],{"href":1722},"\u002Fgetting-started-with-python-excel-automation\u002Fwriting-dataframes-to-excel-with-pandas\u002Fcontrol-how-nan-and-infinity-appear-in-excel-output\u002F","Control How NaN and Infinity Appear in Excel Output",[390,1725,399,1730,399,1733,399,1736,399,1739,399,1746,399,1757,399,1762,399,1766,399,1770,399,1773,399,1778,399,1785,399,1790,399,1795,399,1802,399,1807,399,1811,399,1813,399,1816,399,1820,399,1823,399,1826,399,1832,399,1835,399,1838,399,1840,399,1843,399,1847,399,1850,399,1853,399,1860,399,1864],{"viewBox":1726,"role":393,"ariaLabelledBy":1727,"xmlns":397,"style":1257},"4 0 752 272",[1728,1729],"zd-choose-t","zd-choose-d",[401,1731,1732],{"id":1728},"What to write, and how to show it",[405,1734,1735],{"id":1729},"If the value is genuinely zero, write 0 and use a number format to show a dash or nothing. If the value is missing or not applicable, write a true blank so averages and counts skip it. Never use empty text to stand for zero in a numeric column.",[409,1737],{"x":312,"y":24,"width":1266,"height":1738,"fill":414},"272",[409,1740],{"x":1741,"y":418,"width":1742,"height":1743,"rx":1744,"fill":469,"stroke":470,"style":1745},"240.0","280.0","75.5","12","stroke-width:2px",[1747,1748,1750],"g",{"transform":1749},"translate(368.0,29.0) scale(1.000)",[1751,1752],"path",{"d":1753,"fill":1754,"stroke":1755,"style":1756},"M5 9h14 M4 15h14 M10 4l-2 16 M16 4l-2 16","none","var(--brand-strong,#4338ca)","stroke-width:1.80px;stroke-linecap:round;stroke-linejoin:round",[429,1758,1761],{"x":1759,"y":1743,"style":1760},"380.0","font-size:13.5px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","What does the cell mean?",[49,1763],{"x1":1759,"y1":1764,"x2":1759,"y2":1765,"stroke":470,"style":1745},"91.5","111.5",[49,1767],{"x1":1768,"y1":1765,"x2":1769,"y2":1765,"stroke":470,"style":1745},"134.7","625.3",[49,1771],{"x1":1768,"y1":1765,"x2":1768,"y2":1772,"stroke":470,"style":1745},"157.5",[1774,1775],"polygon",{"points":1776,"fill":1777},"134.7,161.5 129.7,152.5 139.7,152.5","#5b5cf0",[409,1779],{"x":1780,"y":1781,"width":1782,"height":1783,"rx":1784,"fill":414,"stroke":422,"style":1276},"94.9","121.5","79.6","21.0","10",[429,1786,1789],{"x":1768,"y":1787,"style":1788},"136.0","font-size:11.5px;font-weight:700;fill:var(--muted,#5b6780);text-anchor:middle","a real zero",[409,1791],{"x":1270,"y":1792,"width":1793,"height":1794,"rx":1744,"fill":528,"stroke":529,"style":1745},"163.5","229.3","93.0",[1747,1796,1798],{"transform":1797},"translate(122.7,176.5) scale(1.000)",[1751,1799],{"d":1800,"fill":1754,"stroke":1801,"style":1756},"M5 12.5l4.5 4.5L19 7","var(--teal-ink,#0b6157)",[429,1803,1806],{"x":1768,"y":1804,"style":1805},"223.0","font-size:13.5px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","write 0, format as dash",[429,1808,1810],{"x":1768,"y":1809,"style":1311},"242.5","counted in averages",[49,1812],{"x1":1759,"y1":1765,"x2":1759,"y2":1772,"stroke":470,"style":1745},[1774,1814],{"points":1815,"fill":1777},"380.0,161.5 375.0,152.5 385.0,152.5",[409,1817],{"x":1818,"y":1781,"width":1819,"height":1783,"rx":1784,"fill":414,"stroke":422,"style":1276},"349.1","61.8",[429,1821,1822],{"x":1759,"y":1787,"style":1788},"no data",[409,1824],{"x":1825,"y":1792,"width":1793,"height":1794,"rx":1744,"fill":469,"stroke":470,"style":1745},"265.3",[1747,1827,1829],{"transform":1828},"translate(368.0,176.5) scale(1.000)",[1751,1830],{"d":1831,"fill":1754,"stroke":1755,"style":1756},"M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z M12 9a3 3 0 1 0 .01 0z",[429,1833,1834],{"x":1759,"y":1804,"style":1760},"write a blank",[429,1836,1837],{"x":1759,"y":1809,"style":1311},"skipped by averages",[49,1839],{"x1":1769,"y1":1765,"x2":1769,"y2":1772,"stroke":470,"style":1745},[1774,1841],{"points":1842,"fill":1777},"625.3,161.5 620.3,152.5 630.3,152.5",[409,1844],{"x":1845,"y":1781,"width":1846,"height":1783,"rx":1784,"fill":414,"stroke":422,"style":1276},"574.6","101.4",[429,1848,1849],{"x":1769,"y":1787,"style":1788},"tempted by \"\"",[409,1851],{"x":1852,"y":1792,"width":1793,"height":1794,"rx":1744,"fill":541,"stroke":542,"style":1745},"510.7",[1747,1854,1856],{"transform":1855},"translate(613.3,176.5) scale(1.000)",[1751,1857],{"d":1858,"fill":1754,"stroke":1859,"style":1756},"M6 6l12 12 M18 6L6 18","var(--gold-ink,#7a4e06)",[429,1861,1863],{"x":1769,"y":1804,"style":1862},"font-size:13.5px;font-weight:700;fill:var(--gold-ink,#7a4e06);text-anchor:middle","avoid empty text",[429,1865,1866],{"x":1769,"y":1809,"style":1311},"breaks arithmetic",[33,1868,1870],{"id":1869},"step-4-hide-every-zero-on-a-sheet","Step 4 — Hide every zero on a sheet",[10,1872,1873,1874,1877],{},"To hide zeros across an entire sheet — including formula results — Excel has a sheet-level option, ",[73,1875,1876],{},"Show a zero in cells that have zero value",". openpyxl exposes it on the sheet view:",[38,1879,1881],{"className":86,"code":1880,"language":88,"meta":43,"style":43},"wb = load_workbook(\"sales_q3.xlsx\")\nwb.active.sheet_view.showZeros = False\nwb.save(\"sales_q3_nozeros.xlsx\")\n\nimport zipfile\nwith zipfile.ZipFile(\"sales_q3_nozeros.xlsx\") as z:\n    xml = z.read(\"xl\u002Fworksheets\u002Fsheet1.xml\").decode()\nprint(\"showZeros written:\", 'showZeros=\"0\"' in xml)\n",[14,1882,1883,1895,1905,1914,1918,1925,1942,1958],{"__ignoreMap":43},[47,1884,1885,1887,1889,1891,1893],{"class":49,"line":50},[47,1886,159],{"class":99},[47,1888,162],{"class":95},[47,1890,1562],{"class":99},[47,1892,1541],{"class":57},[47,1894,360],{"class":99},[47,1896,1897,1900,1902],{"class":49,"line":109},[47,1898,1899],{"class":99},"wb.active.sheet_view.showZeros ",[47,1901,162],{"class":95},[47,1903,1904],{"class":119}," False\n",[47,1906,1907,1909,1912],{"class":49,"line":116},[47,1908,978],{"class":99},[47,1910,1911],{"class":57},"\"sales_q3_nozeros.xlsx\"",[47,1913,360],{"class":99},[47,1915,1916],{"class":49,"line":129},[47,1917,113],{"emptyLinePlaceholder":112},[47,1919,1920,1922],{"class":49,"line":140},[47,1921,103],{"class":95},[47,1923,1924],{"class":99}," zipfile\n",[47,1926,1927,1930,1933,1935,1937,1939],{"class":49,"line":151},[47,1928,1929],{"class":95},"with",[47,1931,1932],{"class":99}," zipfile.ZipFile(",[47,1934,1911],{"class":57},[47,1936,1147],{"class":99},[47,1938,1150],{"class":95},[47,1940,1941],{"class":99}," z:\n",[47,1943,1944,1947,1949,1952,1955],{"class":49,"line":156},[47,1945,1946],{"class":99},"    xml ",[47,1948,162],{"class":95},[47,1950,1951],{"class":99}," z.read(",[47,1953,1954],{"class":57},"\"xl\u002Fworksheets\u002Fsheet1.xml\"",[47,1956,1957],{"class":99},").decode()\n",[47,1959,1960,1962,1964,1967,1969,1972,1975],{"class":49,"line":168},[47,1961,335],{"class":119},[47,1963,338],{"class":99},[47,1965,1966],{"class":57},"\"showZeros written:\"",[47,1968,199],{"class":99},[47,1970,1971],{"class":57},"'showZeros=\"0\"'",[47,1973,1974],{"class":95}," in",[47,1976,1977],{"class":99}," xml)\n",[10,1979,1980,1981,1984,1985,1988,1989,1992,1993,31],{},"The setting is saved in the sheet's XML as ",[14,1982,1983],{},"showZeros=\"0\""," and Excel honours it when the file is opened; LibreOffice does not read it from ",[14,1986,1987],{},".xlsx"," files, which is why the CSV export cannot be used to check it. Because it is a view setting, it applies to every cell on the sheet and a reader can turn it back on in Excel's options — useful for a dashboard sheet, but a number format is the better tool when only some cells should change. Neither approach alters values, so charts still plot zeros as zero; if a chart should leave a gap instead, the cell needs to be blank or ",[14,1990,1991],{},"#N\u002FA",", as in ",[27,1994,1996],{"href":1995},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fbuild-a-rolling-12-month-chart-on-an-excel-dashboard\u002F","Build a Rolling 12-Month Chart on an Excel Dashboard",[33,1998,2000],{"id":1999},"common-pitfalls","Common pitfalls",[2002,2003,2004,2015,2021,2030,2036],"ul",{},[2005,2006,2007,2014],"li",{},[2008,2009,2010,2011,2013],"strong",{},"Writing ",[14,2012,1228],{}," instead of 0."," It is text: averages, counts and arithmetic change.",[2005,2016,2017,2020],{},[2008,2018,2019],{},"Forgetting the third section."," Two sections apply the negative format to zeros too.",[2005,2022,2023,2026,2027,2029],{},[2008,2024,2025],{},"Misaligned dashes."," Use ",[14,2028,372],{}," so dashes line up with parenthesised negatives.",[2005,2031,2032,2035],{},[2008,2033,2034],{},"Hiding missing data as zeros."," Missing values belong as blanks, not hidden zeros.",[2005,2037,2038,2041],{},[2008,2039,2040],{},"Expecting charts to skip hidden zeros."," They plot the value, not the display.",[33,2043,2045],{"id":2044},"conclusion","Conclusion",[10,2047,2048,2049,2052,2053,2055,2056,2059,2060,2062],{},"To show zeros as dashes, give the number format a third section such as ",[14,2050,2051],{},"\"–\"",", with ",[14,2054,372],{}," padding if negatives use parentheses; to hide them, leave the third section empty, or turn off ",[14,2057,2058],{},"showZeros"," for a whole sheet. Keep real zeros as ",[14,2061,24],{}," and missing values as true blanks — never empty strings — so that averages, counts and arithmetic stay correct, and check the displayed result with a LibreOffice CSV export.",[33,2064,2066],{"id":2065},"frequently-asked-questions","Frequently asked questions",[10,2068,2069,2072],{},[2008,2070,2071],{},"How do I display zeros as dashes in Excel with Python?","\nSet a number format with a zero section, for example #,##0.00;-#,##0.00;\"–\", using openpyxl's cell.number_format.",[10,2074,2075,2078],{},[2008,2076,2077],{},"How do I hide zero values without deleting them?","\nUse a number format whose third section is empty, such as #,##0.00;-#,##0.00;, or set ws.sheet_view.showZeros = False to hide all zeros on a sheet.",[10,2080,2081,2084],{},[2008,2082,2083],{},"Is a hidden zero the same as an empty cell?","\nNo. A hidden zero is still counted by AVERAGE and COUNT, while blank cells and empty strings are skipped; empty strings also cause VALUE errors in arithmetic.",[10,2086,2087,2090,2091,2094],{},[2008,2088,2089],{},"Why do my dashes not line up with negative numbers in parentheses?","\nAdd ",[73,2092,2093],{},") after the positive and zero sections so they reserve the width of a closing parenthesis, as in #,##0.00",");(#,##0.00);\"–\"_).",[33,2096,2098],{"id":2097},"related","Related",[2002,2100,2101,2107,2114,2121],{},[2005,2102,2103,2104,2106],{},"Up one level: ",[27,2105,30],{"href":29}," — number formats from Python.",[2005,2108,2109,2113],{},[27,2110,2112],{"href":2111},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-negative-numbers-in-red-with-parentheses\u002F","Show Negative Numbers in Red with Parentheses"," — the negative section.",[2005,2115,2116,2120],{},[27,2117,2119],{"href":2118},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fread-cell-values-as-displayed-in-excel\u002F","Read Cell Values as Displayed in Excel"," — reading formatted text back.",[2005,2122,2123,2127],{},[27,2124,2126],{"href":2125},"\u002Fadvanced-data-transformation-and-cleaning\u002Fhandling-missing-data-in-excel-reports\u002Fhow-missing-values-change-sums-averages-and-counts\u002F","How Missing Values Change Sums, Averages and Counts"," — the same question in pandas.",[2129,2130,2131],"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 .sSjpA, html code.shiki .sSjpA{--shiki-default:#005CC5;--shiki-dark:#FF9492}",{"title":43,"searchDepth":109,"depth":109,"links":2133},[2134,2135,2136,2137,2139,2140,2141,2142,2143],{"id":35,"depth":109,"text":36},{"id":79,"depth":109,"text":80},{"id":614,"depth":109,"text":615},{"id":1362,"depth":109,"text":2138},"Step 3 — Choose what the cell should be, then how it looks",{"id":1869,"depth":109,"text":1870},{"id":1999,"depth":109,"text":2000},{"id":2044,"depth":109,"text":2045},{"id":2065,"depth":109,"text":2066},{"id":2097,"depth":109,"text":2098},"2026-10-02","Make zero values in a generated Excel report less noisy without changing the data: show them as a dash with the zero section of a number format, hide them in chosen cells or across a whole sheet, keep dashes aligned with the numbers around them, and understand how displayed dashes, hidden zeros, empty strings and true blanks behave in totals, averages and charts.","md",[2148,2150,2152,2154],{"q":2071,"a":2149},"Set a number format with a zero section, for example #,##0.00;-#,##0.00;\"–\", using openpyxl's cell.number_format.",{"q":2077,"a":2151},"Use a number format whose third section is empty, such as #,##0.00;-#,##0.00;, or set ws.sheet_view.showZeros = False to hide all zeros on a sheet.",{"q":2083,"a":2153},"No. A hidden zero is still counted by AVERAGE and COUNT, while blank cells and empty strings are skipped; empty strings also cause VALUE errors in arithmetic.",{"q":2089,"a":2155},"Add _) after the positive and zero sections so they reserve the width of a closing parenthesis, as in #,##0.00_);(#,##0.00);\"–\"_).","show zeros as dashes in excel",null,{"breadcrumb":2159},[2160,2163,2166],{"name":2161,"item":2162},"Home","\u002F",{"name":2164,"item":2165},"Formatting and Charting Excel Reports with Python","\u002Fformatting-and-charting-excel-reports-with-python\u002F",{"name":30,"item":29},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel",{"title":2169,"description":2170},"Show Zeros as Dashes or Hide Them in Excel with Python","Zero display in openpyxl reports: the zero section of a number format for dashes, empty sections to hide zeros, the sheet-level showZeros setting, alignment, and why zero, \"\" and blank differ in AVERAGE, COUNT and charts.","show-zeros-as-dashes-or-hide-them-in-excel","formatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-zeros-as-dashes-or-hide-them-in-excel\u002Findex",[2174],"number-formats","how-to","i7S0SDBJQ3VzepIVOHHwBJtLhD7HnSB--0AjsNKff7M",[2178,2182],{"title":2179,"path":2180,"stem":2181,"children":-1},"Show Units Like kg or Hours with Number Formats","\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-units-like-kg-or-hours-with-number-formats","formatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fshow-units-like-kg-or-hours-with-number-formats\u002Findex",{"title":388,"path":2183,"stem":2184,"children":-1},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fwrite-custom-number-format-codes-in-excel-with-python","formatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel\u002Fwrite-custom-number-format-codes-in-excel-with-python\u002Findex",[2186,2188],{"path":2187,"title":30},"\u002Fformatting-and-charting-excel-reports-with-python\u002Fapplying-number-and-date-formats-in-excel",{"path":2189,"title":2164},"\u002Fformatting-and-charting-excel-reports-with-python",[],[2192,2195,2198,2201,2204,2207],{"path":2193,"title":2194,"kind":2175},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Fconvert-currency-strings-to-numbers-with-pandas","Convert Currency Strings Like \"$1,234.56\" and \"(500)\" to Numbers with pandas",{"path":2196,"title":2197,"kind":2175},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Fconvert-percentage-strings-to-numbers-with-pandas","Convert Percentage Strings Like \"12.5%\" to Numbers with pandas",{"path":2199,"title":2200,"kind":2175},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fexcel-text-function-equivalent-in-pandas","Excel TEXT Function Equivalent in pandas",{"path":2202,"title":2203,"kind":2175},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fmatch-excel-rounding-in-pandas","Match Excel Rounding in pandas",{"path":2205,"title":2206,"kind":2175},"\u002Fadvanced-data-transformation-and-cleaning\u002Fworking-with-dates-and-times-in-excel-data\u002Fconvert-excel-time-values-and-durations","Convert Excel Time Values and Durations in Python",{"path":2208,"title":2209,"kind":2175},"\u002Fautomating-reporting-workflows\u002Fbuilding-multi-sheet-excel-dashboards\u002Fadd-variance-arrows-and-trend-indicators-to-a-dashboard","Add Variance Arrows and Trend Indicators to a Dashboard",1790972107250]