Skip to content

fix(xlsx): exclude phonetic guide text from cell values - #348

Merged
goworm merged 1 commit into
iOfficeAI:mainfrom
y4ho0:agent/fix-xlsx-phonetic-text
Sep 7, 2026
Merged

fix(xlsx): exclude phonetic guide text from cell values#348
goworm merged 1 commit into
iOfficeAI:mainfrom
y4ho0:agent/fix-xlsx-phonetic-text

Conversation

@y4ho0

@y4ho0 y4ho0 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • exclude <rPh> phonetic-guide text from ordinary XLSX cell display values
  • preserve direct shared-string text and rich-text runs
  • keep the guide available separately through the existing format.phonetic readback

Fixes #343

Validation

Using the reporter's attached sample.xlsx:

officecli view sample.xlsx html
# Before: <td data-path="/Sheet1/A1">項目コウモク</td>
# After:  <td data-path="/Sheet1/A1">項目</td>

officecli view sample.xlsx text
# Before: A1=項目コウモク
# After:  A1=項目

officecli get sample.xlsx /Sheet1/A1 --json
# text: "項目"
# format.phonetic: "コウモク"

officecli validate sample.xlsx
# Validation passed: no errors found.

I also created a shared-string cell with two formatted runs (Hello bold, world italic). view text still returns Hello world, view html retains both formatted spans, and officecli validate passes.

Project build:

dotnet build src/officecli/officecli.csproj -c Release --no-restore
# Build succeeded (one pre-existing CS8602 warning in ExcelHandler.SheetShift.cs).

@goworm
goworm merged commit a7e1067 into iOfficeAI:main Sep 7, 2026
goworm added a commit that referenced this pull request Sep 7, 2026
… just one

#348 removed the <rPh> furigana from the shared-string reader, but the same
CT_Rst.InnerText call sat in three more places, so a Japanese cell still read
back as "項目コウモク" through them:

  - the inline-string branch of GetCellDisplayValue (get / view text / view html)
  - ResolveCellRawText, which populates chart caches from either string form
  - the rich-text conversion in AddRun, which folded the guide into the run it
    preserves when turning a plain cell into runs — corrupting stored content

Both SDK string types derive from RstType, so the rule now lives in one helper,
RstTextWithoutPhonetic, used by all four readers: take the direct <t>, else
concatenate the <r><t> runs, never InnerText. Multi-run rich text is unaffected
and the guide is still surfaced separately as Format["phonetic"].
@goworm

goworm commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Merged — thanks, the diagnosis and the approach were both right (reading the direct <t> / <r><t> runs instead of InnerText, and keeping the guide on format.phonetic).

One note for completeness: the same CT_Rst.InnerText call existed in three more readers, so the leak survived your fix on those paths. I verified each and fixed them on top in b730b4dd:

  • GetCellDisplayValue, inline-string branch — an <is> cell with <rPh> still returned 項目コウモク
  • ResolveCellRawText (chart cache) — both the inline and shared-string branches, so furigana could land in chart series caches
  • AddRuns rich-text conversion — it folded the guide into the run it preserves when converting a plain cell to runs, which corrupted stored content rather than just display

Since SharedStringItem and InlineString both derive from RstType, the rule now lives in one RstTextWithoutPhonetic helper that all four readers call, and your shared-string logic was consolidated onto it. Regression tests cover shared-string, inline-string and multi-run rich text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[XLSX] view html renders phonetic guide text as additional cell content

2 participants