Skip to content

Export shared strings with RichText #1099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 6, 2020

Conversation

kigh-ota
Copy link
Contributor

@kigh-ota kigh-ota commented Jan 30, 2020

This PR is intended to fix #633.

When an Excel file is read, a shared string with rich text (<r>) nodes inside is correctly parsed and reconciled into a CellXform object like below.

{
  model: {
    value: { richText: [ ... ] },
    type: Enums.ValueType.RichText,
  },
}

However, XLSX#writeFile() converts this object into an empty cell in the exported Excel file, because CellXform#prepare() and #render() do nothing when model.type === Enums.ValueType.RichText.

To fix this, the both methods now handle RichText in the same way as String.

@alubbe alubbe merged commit 301cd36 into exceljs:master Feb 6, 2020
@Siemienik
Copy link
Member

hmm.. should we add some documentation about these changes?

@kigh-ota
Copy link
Contributor Author

kigh-ota commented Feb 6, 2020

@Siemienik
Which documentation do you mean, for users or for developers?
In my opinion, one for users is not mandatory.
This is because the documentation already includes an example of a rich text value with multiple styles, so users (including me) would expect that the value would be exported as is even without additional description.
https://github.com/exceljs/exceljs/blob/a2eaa9e75e477a9f5c88d54979bd95eb37571c3d/README.md#rich-text

But I'm new here, so tell me if I should consider more :)

@Siemienik
Copy link
Member

@kigh-ota ok, it's my gap, sorry abut this, You are right :)

@kigh-ota
Copy link
Contributor Author

kigh-ota commented Feb 9, 2020

@Siemienik
Thank you for your comments!

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.

Existing Rich Text corrupts .xlsx on write
3 participants