Skip to content
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

Don't render empty rich text substrings #2737

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Blackhol3
Copy link

Excel can't open file with empty rich text substrings. For instance, this code:

const workbook = new Workbook();
const worksheet = workbook.addWorksheet('Test');

worksheet.getCell('C1').value = {
	richText: [
		{font: {size: 10, color: {argb: 'ffff0000'}}, text: 'Test 1'},
		{font: {size: 10, color: {argb: 'ff00ff00'}}, text: ''},       // Empty string
		{font: {size: 10, color: {argb: 'ff0000ff'}}, text: 'Test 2'},
	],
};

workbook.xlsx.writeFile('test.xlsx');

creates a file for which Excel will throw the following error:

We found a problem with some content in 'test.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

Not rendering the empty substring in the XML solves the problem, without changing the appearance of the resulting 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.

None yet

1 participant