@nguyenphp/antigravity-marketing 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +186 -78
  2. package/package.json +4 -3
  3. package/templates/.agent/skills/marketing-report-expert/SKILL.md +70 -0
  4. package/templates/.agent/skills/minimax-docx/LICENSE +21 -0
  5. package/templates/.agent/skills/minimax-docx/SKILL.md +274 -0
  6. package/templates/.agent/skills/minimax-docx/assets/styles/academic_styles.xml +250 -0
  7. package/templates/.agent/skills/minimax-docx/assets/styles/corporate_styles.xml +284 -0
  8. package/templates/.agent/skills/minimax-docx/assets/styles/default_styles.xml +449 -0
  9. package/templates/.agent/skills/minimax-docx/assets/xsd/aesthetic-rules.xsd +470 -0
  10. package/templates/.agent/skills/minimax-docx/assets/xsd/business-rules.xsd +130 -0
  11. package/templates/.agent/skills/minimax-docx/assets/xsd/common-types.xsd +159 -0
  12. package/templates/.agent/skills/minimax-docx/assets/xsd/wml-subset.xsd +589 -0
  13. package/templates/.agent/skills/minimax-docx/references/cjk_typography.md +357 -0
  14. package/templates/.agent/skills/minimax-docx/references/cjk_university_template_guide.md +184 -0
  15. package/templates/.agent/skills/minimax-docx/references/comments_guide.md +191 -0
  16. package/templates/.agent/skills/minimax-docx/references/design_good_bad_examples.md +829 -0
  17. package/templates/.agent/skills/minimax-docx/references/design_principles.md +819 -0
  18. package/templates/.agent/skills/minimax-docx/references/openxml_element_order.md +308 -0
  19. package/templates/.agent/skills/minimax-docx/references/openxml_encyclopedia_part1.md +4061 -0
  20. package/templates/.agent/skills/minimax-docx/references/openxml_encyclopedia_part2.md +2820 -0
  21. package/templates/.agent/skills/minimax-docx/references/openxml_encyclopedia_part3.md +3381 -0
  22. package/templates/.agent/skills/minimax-docx/references/openxml_namespaces.md +82 -0
  23. package/templates/.agent/skills/minimax-docx/references/openxml_units.md +72 -0
  24. package/templates/.agent/skills/minimax-docx/references/scenario_a_create.md +284 -0
  25. package/templates/.agent/skills/minimax-docx/references/scenario_b_edit_content.md +295 -0
  26. package/templates/.agent/skills/minimax-docx/references/scenario_c_apply_template.md +456 -0
  27. package/templates/.agent/skills/minimax-docx/references/track_changes_guide.md +200 -0
  28. package/templates/.agent/skills/minimax-docx/references/troubleshooting.md +506 -0
  29. package/templates/.agent/skills/minimax-docx/references/typography_guide.md +294 -0
  30. package/templates/.agent/skills/minimax-docx/references/xsd_validation_guide.md +158 -0
  31. package/templates/.agent/skills/minimax-docx/scripts/doc_to_docx.sh +40 -0
  32. package/templates/.agent/skills/minimax-docx/scripts/docx_preview.sh +37 -0
  33. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj +19 -0
  34. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli/Program.cs +18 -0
  35. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/AnalyzeCommand.cs +147 -0
  36. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/ApplyTemplateCommand.cs +322 -0
  37. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/CreateCommand.cs +324 -0
  38. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/DiffCommand.cs +155 -0
  39. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/EditContentCommand.cs +487 -0
  40. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/FixOrderCommand.cs +108 -0
  41. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/MergeRunsCommand.cs +122 -0
  42. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/ValidateCommand.cs +107 -0
  43. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/MiniMaxAIDocx.Core.csproj +15 -0
  44. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/CommentSynchronizer.cs +169 -0
  45. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/ElementOrder.cs +80 -0
  46. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/NamespaceConstants.cs +42 -0
  47. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/RunMerger.cs +81 -0
  48. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/StyleAnalyzer.cs +81 -0
  49. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/TrackChangesHelper.cs +99 -0
  50. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/UnitConverter.cs +23 -0
  51. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples.cs +1832 -0
  52. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch1.cs +910 -0
  53. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch2.cs +999 -0
  54. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch3.cs +1048 -0
  55. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch4.cs +1038 -0
  56. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/CharacterFormattingSamples.cs +1020 -0
  57. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/DocumentCreationSamples.cs +1121 -0
  58. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/FieldAndTocSamples.cs +624 -0
  59. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/FootnoteAndCommentSamples.cs +675 -0
  60. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/HeaderFooterSamples.cs +838 -0
  61. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ImageSamples.cs +917 -0
  62. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ListAndNumberingSamples.cs +826 -0
  63. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ParagraphFormattingSamples.cs +1199 -0
  64. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/StyleSystemSamples.cs +1487 -0
  65. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/TableSamples.cs +1163 -0
  66. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/TrackChangesSamples.cs +595 -0
  67. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/CjkHelper.cs +39 -0
  68. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/FontDefaults.cs +24 -0
  69. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/PageSizes.cs +20 -0
  70. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/BusinessRuleValidator.cs +224 -0
  71. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/GateCheckValidator.cs +148 -0
  72. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/ValidationResult.cs +23 -0
  73. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/XsdValidator.cs +69 -0
  74. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.slnx +4 -0
  75. package/templates/.agent/skills/minimax-docx/scripts/env_check.sh +196 -0
  76. package/templates/.agent/skills/minimax-docx/scripts/setup.ps1 +274 -0
  77. package/templates/.agent/skills/minimax-docx/scripts/setup.sh +504 -0
  78. package/templates/.agent/skills/minimax-multimodal-toolkit/SKILL.md +359 -0
  79. package/templates/.agent/skills/minimax-pdf/README.md +222 -0
  80. package/templates/.agent/skills/minimax-pdf/SKILL.md +201 -0
  81. package/templates/.agent/skills/minimax-pdf/design/design.md +381 -0
  82. package/templates/.agent/skills/minimax-pdf/scripts/cover.py +1579 -0
  83. package/templates/.agent/skills/minimax-pdf/scripts/fill_inspect.py +200 -0
  84. package/templates/.agent/skills/minimax-pdf/scripts/fill_write.py +242 -0
  85. package/templates/.agent/skills/minimax-pdf/scripts/make.sh +491 -0
  86. package/templates/.agent/skills/minimax-pdf/scripts/merge.py +112 -0
  87. package/templates/.agent/skills/minimax-pdf/scripts/palette.py +559 -0
  88. package/templates/.agent/skills/minimax-pdf/scripts/reformat_parse.py +374 -0
  89. package/templates/.agent/skills/minimax-pdf/scripts/render_body.py +1055 -0
  90. package/templates/.agent/skills/minimax-pdf/scripts/render_cover.cjs +111 -0
  91. package/templates/.agent/skills/minimax-xlsx/SKILL.md +138 -0
  92. package/templates/.agent/skills/minimax-xlsx/references/create.md +691 -0
  93. package/templates/.agent/skills/minimax-xlsx/references/edit.md +684 -0
  94. package/templates/.agent/skills/minimax-xlsx/references/fix.md +37 -0
  95. package/templates/.agent/skills/minimax-xlsx/references/format.md +768 -0
  96. package/templates/.agent/skills/minimax-xlsx/references/ooxml-cheatsheet.md +231 -0
  97. package/templates/.agent/skills/minimax-xlsx/references/read-analyze.md +97 -0
  98. package/templates/.agent/skills/minimax-xlsx/references/validate.md +772 -0
  99. package/templates/.agent/skills/minimax-xlsx/scripts/formula_check.py +422 -0
  100. package/templates/.agent/skills/minimax-xlsx/scripts/libreoffice_recalc.py +248 -0
  101. package/templates/.agent/skills/minimax-xlsx/scripts/shared_strings_builder.py +163 -0
  102. package/templates/.agent/skills/minimax-xlsx/scripts/style_audit.py +575 -0
  103. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_add_column.py +395 -0
  104. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_insert_row.py +274 -0
  105. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_pack.py +87 -0
  106. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_reader.py +362 -0
  107. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_shift_rows.py +396 -0
  108. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_unpack.py +130 -0
  109. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/[Content_Types].xml +9 -0
  110. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/_rels/.rels +6 -0
  111. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/_rels/workbook.xml.rels +19 -0
  112. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/sharedStrings.xml +33 -0
  113. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/styles.xml +160 -0
  114. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/workbook.xml +30 -0
  115. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/worksheets/sheet1.xml +70 -0
  116. package/templates/.agent/skills/pptx-generator/SKILL.md +249 -0
  117. package/templates/.agent/skills/pptx-generator/references/design-system.md +392 -0
  118. package/templates/.agent/skills/pptx-generator/references/editing.md +162 -0
  119. package/templates/.agent/skills/pptx-generator/references/pitfalls.md +112 -0
  120. package/templates/.agent/skills/pptx-generator/references/pptxgenjs.md +420 -0
  121. package/templates/.agent/skills/pptx-generator/references/slide-types.md +413 -0
  122. package/templates/.agent/skills/tutorial-video-expert/SKILL.md +88 -0
  123. package/templates/.agent/skills/ui-ux-pro-max/SKILL.md +170 -585
  124. package/templates/.agent/skills/vision-analysis/SKILL.md +174 -0
  125. package/templates/.agent/workflows/analyze.md +3 -0
  126. package/templates/.agent/workflows/brand-report.md +44 -0
  127. package/templates/.agent/workflows/report.md +49 -0
@@ -0,0 +1,768 @@
1
+ # Financial Formatting & Output Standards — Complete Agent Guide
2
+
3
+ > This document is the complete reference manual for the agent when applying professional financial formatting to xlsx files. All operations target direct XML surgery on `xl/styles.xml` without using openpyxl. Every operational step provides ready-to-use XML snippets.
4
+
5
+ ---
6
+
7
+ ## 1. When to Use This Path
8
+
9
+ This document (FORMAT path) applies to the following two scenarios:
10
+
11
+ **Scenario A — Dedicated Formatting of an Existing File**
12
+ The user provides an existing xlsx file and requests that financial modeling formatting standards be applied or unified. The starting point is to unpack the file, audit the existing `styles.xml`, then append missing styles and batch-update cell `s` attributes. No cell values or formulas are modified.
13
+
14
+ **Scenario B — Applying Format Standards After CREATE/EDIT**
15
+ After completing data entry or formula writing, formatting is applied as the final step. At this point, `styles.xml` may come from the minimal_xlsx template (which pre-defines 13 style slots) or from a user file. In either case, follow the principle of "append only, never modify existing xf entries."
16
+
17
+ **Not applicable**: Reading or analyzing file contents only (use the READ path); modifying formulas or data (use the EDIT path).
18
+
19
+ ---
20
+
21
+ ## 2. Financial Format Semantic System
22
+
23
+ ### 2.1 Font Color = Cell Role (Color = Role)
24
+
25
+ The primary convention of financial modeling: **font color encodes the cell's role, not decoration**. A reviewer can glance at colors to determine which cells are adjustable parameters and which are model-calculated results. This is an industry-wide convention (followed by investment banks, the Big Four, and corporate finance teams).
26
+
27
+ | Role | Font Color | AARRGGBB | Use Case |
28
+ |------|-----------|----------|----------|
29
+ | Hard-coded input / assumption | Blue | `000000FF` | Growth rates, discount rates, tax rates, and other user-modifiable parameters |
30
+ | Formula / calculated result | Black | `00000000` | All cells containing a `<f>` element |
31
+ | Same-workbook cross-sheet reference | Green | `00008000` | Cells whose formula starts with `SheetName!` |
32
+ | External file link | Red | `00FF0000` | Cells whose formula contains `[FileName.xlsx]` (flagged as fragile links) |
33
+ | Label / text | Black (default) | theme color | Row labels, category headings |
34
+ | Key assumption requiring review | Blue font + yellow fill | Font `000000FF` / Fill `00FFFF00` | Provisional values, parameters pending confirmation |
35
+
36
+ **Decision tree**:
37
+ ```
38
+ Does the cell contain a <f> element?
39
+ +-- Yes -> Does the formula start with [FileName]?
40
+ | +-- Yes -> Red (external link)
41
+ | +-- No -> Does the formula contain SheetName!?
42
+ | +-- Yes -> Green (cross-sheet reference)
43
+ | +-- No -> Black (same-sheet formula)
44
+ +-- No -> Is the value a user-adjustable parameter?
45
+ +-- Yes -> Blue (input/assumption)
46
+ +-- No -> Black default (label)
47
+ ```
48
+
49
+ **Strictly prohibited**: Blue font + `<f>` element coexisting (color role contradiction — must be corrected).
50
+
51
+ ### 2.2 Number Format Matrix
52
+
53
+ | Data Type | formatCode | numFmtId | Display Example | Applicable Scenario |
54
+ |-----------|-----------|----------|-----------------|---------------------|
55
+ | Standard currency (whole dollars) | `$#,##0;($#,##0);"-"` | 164 | $1,234 / ($1,234) / - | P&L, balance sheet amount rows |
56
+ | Standard currency (with cents) | `$#,##0.00;($#,##0.00);"-"` | 169 | $1,234.56 / ($1,234.56) / - | Unit prices, detailed costs |
57
+ | Thousands (K) | `#,##0,"K"` | 171 | 1,234K | Simplified display for management reports |
58
+ | Millions (M) | `#,##0,,"M"` | 172 | 1M | Macro-level summary rows |
59
+ | Percentage (1 decimal) | `0.0%` | 165 | 12.5% | Growth rates, gross margins |
60
+ | Percentage (2 decimals) | `0.00%` | 170 | 12.50% | IRR, precise interest rates |
61
+ | Multiple / valuation multiplier | `0.0x` | 166 | 8.5x | EV/EBITDA, P/E |
62
+ | Integer (thousands separator) | `#,##0` | 167 | 12,345 | Employee count, unit quantities |
63
+ | Year | `0` | 1 (built-in, no declaration needed) | 2024 | Column header years, prevents 2,024 |
64
+ | Date | `m/d/yyyy` | 14 (built-in, no declaration needed) | 3/21/2026 | Timelines |
65
+ | General text | General | 0 (built-in, no declaration needed) | — | Label rows, cells with no format requirement |
66
+
67
+ numFmtId 169–172 are custom formats that need to be appended beyond the 4 formats (164–167) pre-defined in the minimal_xlsx template. When appending, assign IDs according to the rules (see Section 3.4).
68
+
69
+ **Built-in format IDs do not need to be declared in `<numFmts>`** (IDs 0–163 are built into Excel/LibreOffice; simply reference the numFmtId in `<xf>`):
70
+
71
+ | numFmtId | formatCode | Description |
72
+ |----------|-----------|-------------|
73
+ | 0 | General | General format |
74
+ | 1 | `0` | Integer, no thousands separator (use this ID for years) |
75
+ | 3 | `#,##0` | Thousands-separated integer (no decimals) |
76
+ | 9 | `0%` | Percentage integer |
77
+ | 10 | `0.00%` | Percentage with two decimals |
78
+ | 14 | `m/d/yyyy` | Short date |
79
+
80
+ ### 2.3 Negative Number Display Standards
81
+
82
+ Financial reports have two mainstream conventions for negative numbers — choose one and **maintain consistency** throughout the entire workbook:
83
+
84
+ **Parenthetical style (investment banking standard, recommended for external deliverables)**
85
+
86
+ ```
87
+ Positive: $1,234 Negative: ($1,234) Zero: -
88
+ formatCode: $#,##0;($#,##0);"-"
89
+ ```
90
+
91
+ **Red minus sign style (suitable for internal operational analysis reports)**
92
+
93
+ ```
94
+ Positive: $1,234 Negative: -$1,234 (red)
95
+ formatCode: $#,##0;[Red]-$#,##0;"-"
96
+ ```
97
+
98
+ Rule: Once a style is determined, maintain it across the entire workbook. Do not mix two negative number display styles within the same workbook.
99
+
100
+ ### 2.4 Zero Value Display Standards
101
+
102
+ In financial models, "0" and "no data" have different semantics and should be visually distinct:
103
+
104
+ | Scenario | Recommended Display | formatCode Third Segment |
105
+ |----------|-------------------|--------------------------|
106
+ | Sparse matrix (most rows have zero-value periods) | Dash `-` | `"-"` |
107
+ | Quantity counts (zero itself is meaningful) | `0` | `0` or omit |
108
+ | Placeholder row (explicitly empty) | Leave blank | Do not write to cell |
109
+
110
+ Four-segment format syntax: `positive format;negative format;zero value format;text format`
111
+
112
+ Zero as dash: `$#,##0;($#,##0);"-"`
113
+ Zero preserved as 0: `#,##0;(#,##0);0`
114
+
115
+ ---
116
+
117
+ ## 3. styles.xml Surgical Operations
118
+
119
+ ### 3.1 Auditing Existing Styles: Understanding the cellXfs Indirect Reference Chain
120
+
121
+ A cell's `s` attribute points to a position index (0-based) in `cellXfs`, and each `<xf>` entry in `cellXfs` references its respective definition libraries through `fontId`, `fillId`, `borderId`, and `numFmtId`.
122
+
123
+ Reference chain diagram:
124
+
125
+ ```
126
+ Cell <c s="6">
127
+ | Look up cellXfs by 0-based index
128
+ cellXfs[6] -> numFmtId="164" fontId="2" fillId="0" borderId="0"
129
+ | | | |
130
+ numFmts fonts[2] fills[0] borders[0]
131
+ id=164 color=00000000 (no fill) (no border)
132
+ $#,##0... black
133
+ ```
134
+
135
+ Audit steps:
136
+
137
+ **Step 1**: Read `<numFmts>` and record all declared custom formats and their IDs:
138
+ ```xml
139
+ <numFmts count="4">
140
+ <numFmt numFmtId="164" formatCode="$#,##0;($#,##0);&quot;-&quot;"/>
141
+ <numFmt numFmtId="165" formatCode="0.0%"/>
142
+ <numFmt numFmtId="166" formatCode="0.0x"/>
143
+ <numFmt numFmtId="167" formatCode="#,##0"/>
144
+ </numFmts>
145
+ ```
146
+ Record: current maximum custom numFmtId = 167, next available ID = 168.
147
+
148
+ **Step 2**: Read `<fonts>` and list each `<font>` by 0-based index with its color and style:
149
+ ```
150
+ fontId=0 -> No explicit color (theme default black)
151
+ fontId=1 -> color rgb="000000FF" (blue, input role)
152
+ fontId=2 -> color rgb="00000000" (black, formula role)
153
+ fontId=3 -> color rgb="00008000" (green, cross-sheet reference role)
154
+ fontId=4 -> <b/> + color rgb="00000000" (bold black, header)
155
+ ```
156
+
157
+ **Step 3**: Read `<fills>` and confirm that fills[0] and fills[1] are spec-mandated reserved entries (never delete):
158
+ ```
159
+ fillId=0 -> patternType="none" (spec-mandated)
160
+ fillId=1 -> patternType="gray125" (spec-mandated)
161
+ fillId=2 -> Yellow highlight (if present)
162
+ ```
163
+
164
+ **Step 4**: Read `<cellXfs>` and list each `<xf>` entry by 0-based index with its combination:
165
+ ```
166
+ index 0 -> numFmtId=0, fontId=0, fillId=0 -> Default style
167
+ index 1 -> numFmtId=0, fontId=1, fillId=0 -> Blue font general (input)
168
+ index 5 -> numFmtId=164, fontId=1, fillId=0 -> Blue font currency (currency input)
169
+ index 6 -> numFmtId=164, fontId=2, fillId=0 -> Black font currency (currency formula)
170
+ ...
171
+ ```
172
+
173
+ **Step 5**: Verify that all count attributes match the actual number of elements (count mismatches will cause Excel to refuse to open the file).
174
+
175
+ ### 3.2 Safely Appending New Styles (Golden Rule: Append Only, Never Modify Existing xf)
176
+
177
+ **Never modify existing `<xf>` entries**. Modifications will affect all cells that already reference that index, breaking existing formatting. Only append new entries at the end.
178
+
179
+ Complete atomic operation sequence for appending new styles (all 5 steps must be executed):
180
+
181
+ **Step 1**: Determine if a new `<numFmt>` is needed
182
+
183
+ Built-in formats (ID 0–163) skip this step. Custom formats are appended to the end of `<numFmts>`:
184
+ ```xml
185
+ <numFmts count="5"> <!-- count +1 -->
186
+ <!-- Keep existing entries unchanged -->
187
+ <numFmt numFmtId="164" formatCode="$#,##0;($#,##0);&quot;-&quot;"/>
188
+ <numFmt numFmtId="165" formatCode="0.0%"/>
189
+ <numFmt numFmtId="166" formatCode="0.0x"/>
190
+ <numFmt numFmtId="167" formatCode="#,##0"/>
191
+ <!-- Newly appended -->
192
+ <numFmt numFmtId="168" formatCode="$#,##0.00;($#,##0.00);&quot;-&quot;"/>
193
+ </numFmts>
194
+ ```
195
+
196
+ **Step 2**: Determine if a new `<font>` is needed
197
+
198
+ Check whether the existing fonts already contain a matching color+style combination. If not, append to the end of `<fonts>`:
199
+ ```xml
200
+ <fonts count="6"> <!-- count +1 -->
201
+ <!-- Keep existing entries unchanged -->
202
+ ...
203
+ <!-- Newly appended: red font (external link role), new fontId = 5 -->
204
+ <font>
205
+ <sz val="11"/>
206
+ <name val="Calibri"/>
207
+ <color rgb="00FF0000"/>
208
+ </font>
209
+ </fonts>
210
+ ```
211
+ New fontId = the count value before appending (when original count=5, new fontId=5).
212
+
213
+ **Step 3**: Determine if a new `<fill>` is needed
214
+
215
+ If a new background color is needed, append to the end of `<fills>` (note: fills[0] and fills[1] must never be modified):
216
+ ```xml
217
+ <fills count="4"> <!-- count +1 -->
218
+ <fill><patternFill patternType="none"/></fill> <!-- 0: spec-mandated -->
219
+ <fill><patternFill patternType="gray125"/></fill> <!-- 1: spec-mandated -->
220
+ <fill> <!-- 2: yellow highlight -->
221
+ <patternFill patternType="solid">
222
+ <fgColor rgb="00FFFF00"/>
223
+ <bgColor indexed="64"/>
224
+ </patternFill>
225
+ </fill>
226
+ <!-- Newly appended: light gray fill (projection period distinction), new fillId = 3 -->
227
+ <fill>
228
+ <patternFill patternType="solid">
229
+ <fgColor rgb="00D3D3D3"/>
230
+ <bgColor indexed="64"/>
231
+ </patternFill>
232
+ </fill>
233
+ </fills>
234
+ ```
235
+
236
+ **Step 4**: Append a new `<xf>` combination at the end of `<cellXfs>`
237
+ ```xml
238
+ <cellXfs count="14"> <!-- count +1 -->
239
+ <!-- Keep existing entries 0-12 unchanged -->
240
+ ...
241
+ <!-- Newly appended index=13: currency with cents formula (black font + numFmtId=168) -->
242
+ <xf numFmtId="168" fontId="2" fillId="0" borderId="0" xfId="0"
243
+ applyFont="1" applyNumberFormat="1"/>
244
+ </cellXfs>
245
+ ```
246
+ New style index = the count value before appending (when original count=13, new index=13).
247
+
248
+ **Step 5**: Record the new style index; subsequently set the `s` attribute of corresponding cells in the sheet XML to this value.
249
+
250
+ ### 3.3 AARRGGBB Color Format Explanation
251
+
252
+ OOXML's `rgb` attribute uses **8-digit hexadecimal AARRGGBB** format (not HTML's 6-digit RRGGBB):
253
+
254
+ ```
255
+ AA RR GG BB
256
+ | | | |
257
+ Alpha Red Green Blue
258
+ ```
259
+
260
+ - Alpha channel: `00` = fully opaque (normal use value); `FF` = fully transparent (invisible, never use this)
261
+ - Financial color standards always use `00` as the Alpha prefix
262
+
263
+ | Color | AARRGGBB | Corresponding Role |
264
+ |-------|----------|-------------------|
265
+ | Blue (input) | `000000FF` | Hard-coded assumptions |
266
+ | Black (formula) | `00000000` | Calculated results |
267
+ | Green (cross-sheet reference) | `00008000` | Same-workbook cross-sheet |
268
+ | Red (external link) | `00FF0000` | References to other files |
269
+ | Yellow (review-required fill) | `00FFFF00` | Key assumption highlight |
270
+ | Light gray (projection period fill) | `00D3D3D3` | Distinguishing historical vs. forecast periods |
271
+ | White | `00FFFFFF` | Pure white fill |
272
+
273
+ **Common mistake**: Mistakenly writing HTML format `#0000FF` as `FF0000FF` (Alpha=FF makes the color fully transparent and invisible). Correct format: `000000FF`.
274
+
275
+ ### 3.4 numFmtId Assignment Rules
276
+
277
+ ```
278
+ ID 0-163 -> Excel/LibreOffice built-in formats, no declaration needed in <numFmts>, reference directly in <xf>
279
+ ID 164+ -> Custom formats, must be explicitly declared as <numFmt> elements in <numFmts>
280
+ ```
281
+
282
+ Rules for assigning new IDs:
283
+ 1. Read all `numFmtId` attribute values in the current `<numFmts>`
284
+ 2. Take the maximum value + 1 as the next custom format ID
285
+ 3. Do not reuse existing IDs; do not skip numbers
286
+
287
+ The minimal_xlsx template pre-defines IDs: 164, 165, 166, 167. The next available ID is 168.
288
+
289
+ ---
290
+
291
+ ## 4. Pre-defined Style Index Complete Reference Table (13 Slots)
292
+
293
+ The following are the 13 style slots (cellXfs index 0–12) pre-defined in the minimal_xlsx template's `styles.xml`, which can be directly referenced in the cell `s` attribute in sheet XML:
294
+
295
+ | Index | Semantic Role | Font Color | Fill | numFmtId | Format Display | Typical Use |
296
+ |-------|--------------|------------|------|----------|---------------|-------------|
297
+ | **0** | Default style | Theme black | None | 0 | General | Cells requiring no special formatting |
298
+ | **1** | Input / assumption (general) | Blue `000000FF` | None | 0 | General | Text-type assumptions, flags |
299
+ | **2** | Formula / calculated result (general) | Black `00000000` | None | 0 | General | Text concatenation formulas, non-numeric calculations |
300
+ | **3** | Cross-sheet reference (general) | Green `00008000` | None | 0 | General | Values pulled from cross-sheet (general format) |
301
+ | **4** | Header (bold) | Bold black | None | 0 | General | Row/column headings |
302
+ | **5** | Currency input | Blue `000000FF` | None | 164 | $1,234 / ($1,234) / - | Amount inputs in the assumptions area |
303
+ | **6** | Currency formula | Black `00000000` | None | 164 | $1,234 / ($1,234) / - | Amount calculations in the model area (revenue, EBITDA) |
304
+ | **7** | Percentage input | Blue `000000FF` | None | 165 | 12.5% | Rate inputs in the assumptions area (growth rate, gross margin assumptions) |
305
+ | **8** | Percentage formula | Black `00000000` | None | 165 | 12.5% | Rate calculations in the model area (actual gross margin) |
306
+ | **9** | Integer (comma) input | Blue `000000FF` | None | 167 | 12,345 | Quantity inputs in the assumptions area (employee count) |
307
+ | **10** | Integer (comma) formula | Black `00000000` | None | 167 | 12,345 | Quantity calculations in the model area |
308
+ | **11** | Year input | Blue `000000FF` | None | 1 | 2024 | Column header years (no thousands separator) |
309
+ | **12** | Key assumption highlight | Blue `000000FF` | Yellow `00FFFF00` | 0 | General | Key parameters pending review or confirmation |
310
+
311
+ **Selection guide**:
312
+ - Determine "input" vs. "formula" -> Choose odd-numbered (input/blue) or even-numbered (formula/black) paired slots
313
+ - Determine data type -> Choose the corresponding currency (5/6) / percentage (7/8) / integer (9/10) / year (11) slot
314
+ - Cross-sheet reference needing number format -> Append a new green + number format combination (see Section 5.4)
315
+ - Parameter pending review -> index 12
316
+
317
+ ---
318
+
319
+ ## 5. Assumption Separation Principle: XML-Level Implementation
320
+
321
+ ### 5.1 Structural Design
322
+
323
+ Assumption separation principle: **Input assumptions are centralized in a dedicated area (sheet or block); the model calculation area contains only formulas, no hard-coded values**.
324
+
325
+ Recommended structure:
326
+ ```
327
+ Workbook sheet layout
328
+ sheet 1 "Assumptions" -> All blue-font cells (style 1/5/7/9/11/12)
329
+ sheet 2 "Model" -> All black or green-font cells (style 2/3/4/6/8/10)
330
+ ```
331
+
332
+ Same-sheet zoning approach for simple models:
333
+ ```
334
+ Rows 1-5: [Assumptions block - blue font]
335
+ Row 6: [Empty row separator]
336
+ Rows 7+: [Model block - black/green font formulas referencing assumptions area]
337
+ ```
338
+
339
+ ### 5.2 Assumptions Area XML Example
340
+
341
+ ```xml
342
+ <!-- Assumptions sheet (sheet1.xml) example -->
343
+
344
+ <!-- Row 1: Block title -->
345
+ <row r="1">
346
+ <c r="A1" s="4" t="inlineStr"><is><t>Model Assumptions</t></is></c>
347
+ </row>
348
+
349
+ <!-- Row 2: Growth rate assumption - blue font percentage input, s="7" -->
350
+ <row r="2">
351
+ <c r="A2" t="inlineStr"><is><t>Revenue Growth Rate</t></is></c>
352
+ <c r="B2" s="7"><v>0.08</v></c>
353
+ </row>
354
+
355
+ <!-- Row 3: Gross margin assumption - blue font percentage input, s="7" -->
356
+ <row r="3">
357
+ <c r="A3" t="inlineStr"><is><t>Gross Margin</t></is></c>
358
+ <c r="B3" s="7"><v>0.65</v></c>
359
+ </row>
360
+
361
+ <!-- Row 4: Base revenue - blue font currency input, s="5" -->
362
+ <row r="4">
363
+ <c r="A4" t="inlineStr"><is><t>Base Revenue (Year 0)</t></is></c>
364
+ <c r="B4" s="5"><v>1000000</v></c>
365
+ </row>
366
+
367
+ <!-- Row 5: Key assumption (pending review) - blue font yellow fill, s="12" -->
368
+ <row r="5">
369
+ <c r="A5" t="inlineStr"><is><t>Terminal Growth Rate</t></is></c>
370
+ <c r="B5" s="12"><v>0.03</v></c>
371
+ </row>
372
+ ```
373
+
374
+ ### 5.3 Model Area XML Example (Referencing Assumptions Area)
375
+
376
+ ```xml
377
+ <!-- Model sheet (sheet2.xml) example -->
378
+
379
+ <!-- Row 1: Column headers (years) - bold header, s="4"; year cells, s="11" -->
380
+ <row r="1">
381
+ <c r="A1" s="4" t="inlineStr"><is><t>Metric</t></is></c>
382
+ <c r="B1" s="11"><v>2024</v></c>
383
+ <c r="C1" s="11"><v>2025</v></c>
384
+ <c r="D1" s="11"><v>2026</v></c>
385
+ </row>
386
+
387
+ <!-- Row 2: Revenue row -->
388
+ <row r="2">
389
+ <c r="A2" t="inlineStr"><is><t>Revenue</t></is></c>
390
+ <!-- B2: Base year revenue, cross-sheet reference from Assumptions, green, s="3" (general format) -->
391
+ <!-- If currency format is needed, append new style s="13" (see Section 5.4) -->
392
+ <c r="B2" s="3"><f>Assumptions!B4</f><v></v></c>
393
+ <!-- C2, D2: Next year revenue = prior year * (1 + growth rate), black font currency formula, s="6" -->
394
+ <c r="C2" s="6"><f>B2*(1+Assumptions!B2)</f><v></v></c>
395
+ <c r="D2" s="6"><f>C2*(1+Assumptions!B2)</f><v></v></c>
396
+ </row>
397
+
398
+ <!-- Row 3: Gross profit row - black font currency formula, s="6" -->
399
+ <row r="3">
400
+ <c r="A3" t="inlineStr"><is><t>Gross Profit</t></is></c>
401
+ <c r="B3" s="6"><f>B2*Assumptions!B3</f><v></v></c>
402
+ <c r="C3" s="6"><f>C2*Assumptions!B3</f><v></v></c>
403
+ <c r="D3" s="6"><f>D2*Assumptions!B3</f><v></v></c>
404
+ </row>
405
+
406
+ <!-- Row 4: Gross margin row - black font percentage formula, s="8" -->
407
+ <row r="4">
408
+ <c r="A4" t="inlineStr"><is><t>Gross Margin %</t></is></c>
409
+ <c r="B4" s="8"><f>B3/B2</f><v></v></c>
410
+ <c r="C4" s="8"><f>C3/C2</f><v></v></c>
411
+ <c r="D4" s="8"><f>D3/D2</f><v></v></c>
412
+ </row>
413
+ ```
414
+
415
+ ### 5.4 Appending "Green + Number Format" Combinations
416
+
417
+ Pre-defined index 3 is green font + general format. If a cross-sheet reference involves a currency amount, a green style with a number format must be appended:
418
+
419
+ ```xml
420
+ <!-- Append at the end of <cellXfs> in styles.xml (assuming current count=13, new index=13) -->
421
+ <!-- index 13: cross-sheet reference + currency format (green font + $#,##0) -->
422
+ <xf numFmtId="164" fontId="3" fillId="0" borderId="0" xfId="0"
423
+ applyFont="1" applyNumberFormat="1"/>
424
+ <!-- Update count to 14 -->
425
+ ```
426
+
427
+ After appending, cross-sheet reference currency cells use `s="13"`.
428
+
429
+ ---
430
+
431
+ ## 6. Complete Operational Workflow
432
+
433
+ ### 6.1 Workflow Overview
434
+
435
+ ```
436
+ [Existing xlsx or file after CREATE/EDIT]
437
+ |
438
+ Step 1: Unpack (extract to temporary directory)
439
+ |
440
+ Step 2: Audit styles.xml (review existing styles, build index mapping table)
441
+ |
442
+ Step 3: Audit sheet XML (identify cells needing formatting and their semantic roles)
443
+ |
444
+ Step 4: Append missing styles (numFmt -> font -> fill -> xf, update counts)
445
+ |
446
+ Step 5: Batch-update the s attribute of each cell in the sheet XML
447
+ |
448
+ Step 6: XML validity + style reference integrity verification
449
+ |
450
+ Step 7: Pack (recompress as xlsx)
451
+ ```
452
+
453
+ ### 6.2 Step 1 — Unpack
454
+
455
+ ```bash
456
+ python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_fmt/
457
+ ```
458
+
459
+ If the script is unavailable, unpack manually:
460
+ ```bash
461
+ mkdir -p /tmp/xlsx_fmt && cp input.xlsx /tmp/xlsx_fmt/input.xlsx
462
+ cd /tmp/xlsx_fmt && unzip input.xlsx -d unpacked/
463
+ ```
464
+
465
+ ### 6.3 Step 2 — Audit styles.xml
466
+
467
+ Execute according to the method in Section 3.1. Quick check for minimal_xlsx template initial state:
468
+ - `<cellXfs count="13">` and `<numFmts count="4">` -> Template initial state, all 13 pre-defined slots can be used directly
469
+ - Otherwise -> A complete review of the existing index mapping is required
470
+
471
+ ### 6.4 Step 3 — Audit Sheet XML, Build Formatting Plan
472
+
473
+ Read `xl/worksheets/sheet*.xml` and evaluate each cell:
474
+ 1. Does it contain a `<f>` element (formula)? -> Requires black/green/red style
475
+ 2. Is it a hard-coded numeric parameter? -> Requires blue style
476
+ 3. Is the data type currency/percentage/integer/year? -> Select the corresponding number format slot
477
+ 4. Is it a header? -> Bold style (index 4)
478
+
479
+ Build a formatting mapping table: `{cell coordinate: target style index}`
480
+
481
+ ### 6.5 Step 4 — Append Styles
482
+
483
+ Execute according to the atomic operation sequence in Section 3.2. Update the corresponding count attribute immediately after appending each component.
484
+
485
+ ### 6.6 Step 5 — Batch-Update Cell s Attributes
486
+
487
+ ```xml
488
+ <!-- Before formatting: no style -->
489
+ <c r="B5"><v>0.08</v></c>
490
+
491
+ <!-- After formatting: growth rate assumption, blue font percentage, s="7" -->
492
+ <c r="B5" s="7"><v>0.08</v></c>
493
+ ```
494
+
495
+ ```xml
496
+ <!-- Before formatting: formula without style -->
497
+ <c r="C10"><f>B10*(1+Assumptions!B2)</f><v></v></c>
498
+
499
+ <!-- After formatting: currency formula, black font, s="6" -->
500
+ <c r="C10" s="6"><f>B10*(1+Assumptions!B2)</f><v></v></c>
501
+ ```
502
+
503
+ For consecutive rows of the same type, row-level default styles can be used to reduce repetition:
504
+ ```xml
505
+ <!-- Entire row uses style=6, only override for exception cells -->
506
+ <row r="5" s="6" customFormat="1">
507
+ <c r="A5" s="0" t="inlineStr"><is><t>Operating Income</t></is></c> <!-- Text overridden to default -->
508
+ <c r="B5"><f>B3-B4</f><v></v></c> <!-- Inherits row-level s=6 -->
509
+ <c r="C5"><f>C3-C4</f><v></v></c>
510
+ </row>
511
+ ```
512
+
513
+ ### 6.7 Step 6 — Verification
514
+
515
+ ```bash
516
+ # XML validity verification is handled automatically by xlsx_pack.py, no need to manually run xmllint
517
+ # The pack script validates styles.xml and sheet XML legality before packaging; it aborts and reports on errors
518
+
519
+ # Style audit (optional, audit the entire unpacked directory after formatting is complete)
520
+ python3 SKILL_DIR/scripts/style_audit.py /tmp/xlsx_fmt/unpacked/
521
+
522
+ # Formula error static scan (must specify a single .xlsx file, does not accept directories)
523
+ # Pack first, then scan:
524
+ python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_fmt/unpacked/ /tmp/output.xlsx
525
+ python3 SKILL_DIR/scripts/formula_check.py /tmp/output.xlsx
526
+ ```
527
+
528
+ Manual style reference integrity check:
529
+ ```bash
530
+ # Find the maximum s attribute value in the sheet XML
531
+ grep -o 's="[0-9]*"' /tmp/xlsx_fmt/unpacked/xl/worksheets/sheet1.xml \
532
+ | grep -o '[0-9]*' | sort -n | tail -1
533
+
534
+ # Compare with the cellXfs count attribute (max s value must be < count)
535
+ grep 'cellXfs count' /tmp/xlsx_fmt/unpacked/xl/styles.xml
536
+ ```
537
+
538
+ ### 6.8 Step 7 — Pack
539
+
540
+ ```bash
541
+ python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_fmt/unpacked/ output.xlsx
542
+ ```
543
+
544
+ If the script is unavailable, pack manually:
545
+ ```bash
546
+ cd /tmp/xlsx_fmt/unpacked/
547
+ zip -r ../output.xlsx . -x "*.DS_Store"
548
+ ```
549
+
550
+ ---
551
+
552
+ ## 7. Formatting Completeness Checklist
553
+
554
+ Verify each item before delivery:
555
+
556
+ ### Color Role Consistency
557
+ - [ ] All numeric cells containing `<f>` elements: fontId corresponds to black (formula) or green (cross-sheet reference)
558
+ - [ ] All hard-coded numeric values that are user-adjustable parameters: fontId corresponds to blue (input)
559
+ - [ ] Cross-sheet references (formula contains `SheetName!`): fontId corresponds to green
560
+ - [ ] External file references (formula contains `[FileName.xlsx]`): fontId corresponds to red
561
+ - [ ] No cell simultaneously contains a `<f>` element and uses blue font (color role contradiction)
562
+
563
+ ### Number Format Correctness
564
+ - [ ] Year columns: numFmtId="1" (`0` format), displays as 2024 not 2,024
565
+ - [ ] Currency rows: numFmtId="164" or variant, negative numbers display as ($1,234) not -$1,234
566
+ - [ ] Percentage rows: values stored as decimals (0.08 = 8%), format numFmtId="165", displays as 8.0%
567
+ - [ ] Zero values: displayed as `-` in sparse matrices rather than `0` (formatCode third segment contains `"-"`)
568
+ - [ ] Multiple rows (EV/EBITDA, etc.): numFmtId="166" (`0.0x` format)
569
+ - [ ] Negative number display style is consistent throughout the entire workbook (parenthetical or red minus sign)
570
+
571
+ ### styles.xml Structural Integrity
572
+ - [ ] `<numFmts count>` = actual number of `<numFmt>` elements
573
+ - [ ] `<fonts count>` = actual number of `<font>` elements
574
+ - [ ] `<fills count>` = actual number of `<fill>` elements (including spec-mandated fills[0] and fills[1])
575
+ - [ ] `<cellXfs count>` = actual number of `<xf>` elements
576
+ - [ ] fills[0] is `patternType="none"`, fills[1] is `patternType="gray125"` (spec-mandated)
577
+ - [ ] All `<xf>` referenced fontId / fillId / borderId are within the valid range of their respective collections
578
+ - [ ] All cell `s` attribute values < `cellXfs count` (no out-of-bounds references)
579
+
580
+ ### Assumption Separation Verification
581
+ - [ ] No black-font numeric cells in the assumptions area/sheet (black numeric = formula, should not be in assumptions)
582
+ - [ ] No blue-font non-year numeric cells in the model area/sheet (blue numeric = hard-coded, should be in assumptions)
583
+ - [ ] Input parameters in the model area reference the assumptions area via formulas, not by directly copying values
584
+
585
+ ### Formula and Format Linkage
586
+ - [ ] All cells with `<f>` elements have an explicit `s` attribute (must not use default style=0, whose font color is not explicitly black)
587
+ - [ ] SUM summary rows: style uses black font + corresponding number format (e.g., s="6" for currency summaries)
588
+ - [ ] Percentage formulas: values stored as decimals, format is `0.0%`; do not multiply values by 100 before applying percentage format
589
+
590
+ ### Visual Hierarchy
591
+ - [ ] Header rows (years/metric names): style=4 (bold black)
592
+ - [ ] Summary rows (Total/EBITDA/Net Income): bold + corresponding number format (append style if needed)
593
+ - [ ] Unit description rows (e.g., "$ thousands"): use style=0 or style=2 (blue not needed)
594
+
595
+ ---
596
+
597
+ ## 8. Prohibited Actions (What You Must NOT Do)
598
+
599
+ - **Do not modify existing `<xf>` entries**: This will batch-change the style of all cells referencing that index
600
+ - **Do not delete fills[0] and fills[1]**: Required by OOXML specification; deletion causes file corruption
601
+ - **Do not modify cell values or formulas**: The FORMAT path only changes styles, not content
602
+ - **Do not use openpyxl for formatting**: openpyxl rewrites the entire styles.xml on save, losing unsupported features
603
+ - **Do not apply global override styles**: Do not cover the entire workbook with a single style; assign precisely by semantic role
604
+ - **Do not write FF in the Alpha channel**: `rgb="FF0000FF"` makes the color fully transparent; the correct format is `rgb="000000FF"`
605
+
606
+ ---
607
+
608
+ ## 9. Common Errors and Fixes
609
+
610
+ ### Error 1: Year displays as 2,024
611
+
612
+ Cause: The year cell's `s` attribute uses a format with thousands separator (e.g., numFmtId="3" or numFmtId="167").
613
+
614
+ ```xml
615
+ <!-- Incorrect -->
616
+ <c r="B1" s="9"><v>2024</v></c>
617
+
618
+ <!-- Fix: Change to s="11" (numFmtId="1", format 0) -->
619
+ <c r="B1" s="11"><v>2024</v></c>
620
+ ```
621
+
622
+ ### Error 2: Percentage displays as 800% (value was multiplied by 100)
623
+
624
+ Cause: 8% was stored as `<v>8</v>` instead of `<v>0.08</v>`. Excel's `%` format automatically multiplies the value by 100 for display.
625
+
626
+ ```xml
627
+ <!-- Incorrect -->
628
+ <c r="B2" s="7"><v>8</v></c>
629
+
630
+ <!-- Fix: Value must be stored in decimal form -->
631
+ <c r="B2" s="7"><v>0.08</v></c>
632
+ ```
633
+
634
+ ### Error 3: File corruption after appending styles without updating count
635
+
636
+ Cause: A `<font>` or `<xf>` element was appended but the count attribute was not updated; Excel reads beyond bounds using the old count.
637
+
638
+ Fix: Update the corresponding count immediately after appending each element:
639
+ ```xml
640
+ <!-- After appending the 6th font, count must be changed from 5 to 6 -->
641
+ <fonts count="6">
642
+ ...
643
+ </fonts>
644
+ ```
645
+
646
+ ### Error 4: Blue font + formula (color role contradiction)
647
+
648
+ Cause: A formula cell mistakenly uses an input style (e.g., s="5" for currency input).
649
+
650
+ ```xml
651
+ <!-- Incorrect: Formula cell uses blue input style -->
652
+ <c r="C5" s="5"><f>B5*1.08</f><v></v></c>
653
+
654
+ <!-- Fix: Change formula cell to corresponding black formula style (5->6, 7->8, 9->10) -->
655
+ <c r="C5" s="6"><f>B5*1.08</f><v></v></c>
656
+ ```
657
+
658
+ ### Error 5: AARRGGBB color missing Alpha (only 6 digits)
659
+
660
+ ```xml
661
+ <!-- Incorrect: 6-digit format, behavior depends on implementation, usually causes wrong color -->
662
+ <color rgb="0000FF"/>
663
+
664
+ <!-- Fix: Always use 8-digit AARRGGBB, Alpha fixed at 00 -->
665
+ <color rgb="000000FF"/>
666
+ ```
667
+
668
+ ### Error 6: Modifying existing xf (affects all cells referencing that index)
669
+
670
+ Cause: Directly modifying attributes of the Nth `<xf>` in cellXfs, causing all cells with `s="N"` to be batch-changed.
671
+
672
+ Fix: Keep existing entries unchanged, append a new entry at the end, and only change the `s` attribute of cells that need the new style to the new index:
673
+ ```xml
674
+ <!-- Incorrect: Modified the existing xf at index=6 -->
675
+ <xf numFmtId="164" fontId="2" fillId="0" borderId="0" xfId="0"
676
+ applyFont="1" applyNumberFormat="1" applyAlignment="1">
677
+ <alignment horizontal="right"/> <!-- New attribute added, affects ALL cells already using s="6" -->
678
+ </xf>
679
+
680
+ <!-- Fix: Append new index (when original count=13, new index=13), only change the s attribute of cells needing right alignment -->
681
+ <!-- Keep index=6 as-is -->
682
+ <xf numFmtId="164" fontId="2" fillId="0" borderId="0" xfId="0"
683
+ applyFont="1" applyNumberFormat="1" applyAlignment="1">
684
+ <alignment horizontal="right"/>
685
+ </xf> <!-- New index=13 -->
686
+ ```
687
+
688
+ ---
689
+
690
+ ## 10. Financial Model Structure Conventions
691
+
692
+ ### 10.1 Header Rows
693
+
694
+ - Bold font (corresponds to style index 4 in this skill's template)
695
+ - Year columns: use number format `0` (numFmtId="1", no thousands separator) to prevent 2024 from displaying as 2,024
696
+ - A unit description row may be added below headers: gray or italic text, e.g., "$ thousands" or "% of Revenue"
697
+
698
+ ### 10.2 Row Type Standards
699
+
700
+ | Row Type | Style Recommendation | Example |
701
+ |----------|---------------------|---------|
702
+ | Category heading row | Bold, optionally with fill color | "Revenue" |
703
+ | Line item row | Normal style | "Product A", "Product B" |
704
+ | Subtotal row | Bold + top border | "Total Revenue" |
705
+ | Operating metric row | Normal style | "Gross Margin %" |
706
+ | Separator row | Empty row | (empty) |
707
+
708
+ ### 10.3 Multi-Year Model Column Layout
709
+
710
+ ```
711
+ Col A: Label column (width 28, left-aligned text, s="4" for headers or s="0" for labels)
712
+ Col B: FY2022 Actual (width 12, year header s="11", data cells styled by semantic role)
713
+ Col C: FY2023 Actual
714
+ Col D: FY2024E (forecast period - can use light gray fill fillId=3 to differentiate)
715
+ Col E: FY2025E
716
+ Col F: FY2026E
717
+ ```
718
+
719
+ ### 10.4 Cross-Sheet Reference Patterns
720
+
721
+ Complete XML example of parameters passing from assumptions sheet to model sheet:
722
+
723
+ ```xml
724
+ <!-- Assumptions sheet, cell B5: 8% growth rate, blue percentage input -->
725
+ <c r="B5" s="7"><v>0.08</v></c>
726
+
727
+ <!-- Model sheet, cell C10: references assumption area growth rate, green percentage formula -->
728
+ <!-- Requires appending index=13: green + percentage format (fontId=3, numFmtId=165) -->
729
+ <c r="C10" s="13"><f>Assumptions!B5</f><v></v></c>
730
+ ```
731
+
732
+ ---
733
+
734
+ ## 11. Assumption Categories
735
+
736
+ In the assumptions area (Assumptions sheet or assumptions block), organize assumptions in the following standard order for ease of review and maintenance:
737
+
738
+ 1. **Revenue assumptions**: Growth rates, pricing, sales volume
739
+ 2. **Cost assumptions**: Gross margin, fixed/variable cost ratios
740
+ 3. **Working capital**: DSO (Days Sales Outstanding), DPO (Days Payable Outstanding), inventory days
741
+ 4. **Capital expenditures (CapEx)**: As a percentage of revenue or absolute amounts
742
+ 5. **Financing assumptions**: Interest rates, debt repayment schedules
743
+ 6. **Tax and other**: Effective tax rate, depreciation & amortization (D&A)
744
+
745
+ ---
746
+
747
+ ## 12. Audit Trail Best Practices
748
+
749
+ - Use `s="12"` (blue font + yellow fill highlight) to mark cells requiring review or pending changes, making them immediately visible to reviewers
750
+ - In sensitivity analysis rows or a separate Sensitivity tab, show the impact of +/-1% changes in key assumptions on results
751
+ - **Do not hide rows containing assumptions**: Assumption rows must be visible to reviewers; do not use the `hidden="1"` attribute
752
+ - Note a "Last Updated" date at the top of the assumptions area or in a dedicated cell, recording the last modification time of the model
753
+
754
+ ---
755
+
756
+ ## 13. Pre-Delivery Checklist (Common Financial Model Checklist)
757
+
758
+ Before outputting the final file, confirm each item:
759
+
760
+ - [ ] Formula rows contain no hard-coded values (can use `formula_check.py` to scan the packaged `.xlsx` file)
761
+ - [ ] Year columns display as 2024 not 2,024 (numFmtId="1", format `0`)
762
+ - [ ] Negative numbers display as (1,234) not -1,234 (use parenthetical style for externally delivered financial reports)
763
+ - [ ] Zero values display as `-` in sparse rows rather than `0` (formatCode third segment is `"-"`)
764
+ - [ ] Growth rates and percentages are stored as decimals (0.08 = 8%), format is `0.0%`
765
+ - [ ] All cross-sheet reference cells use green font (style index 3 or an appended green + number format combination)
766
+ - [ ] Assumptions block and model block are clearly separated (different sheets or separated by empty rows within the same sheet)
767
+ - [ ] Summary rows use `SUM()` formulas, not manually hard-coded totals
768
+ - [ ] Balance verification: summary rows = sum of their respective line items (a check row can be added at the end of the model to verify)