Skip to content

Existing Rich Text corrupts .xlsx on write #633

@LumaLivy

Description

@LumaLivy

My current program reads in an existing .xlsx that contains a few cells with values that look like this (this was made in excel and I haven't created the structure with JavaScript in any way):

{ richText:
   [ { font:
        { bold: true,
          size: 10,
          color: { theme: 1 },
          name: 'Arial',
          family: 2 },
       text: '(j) ' },
     { font: { size: 10, color: { theme: 1 }, name: 'Arial', family: 2 },
       text: 'blah blah blah ' },
     { font:
        { bold: true,
          underline: true,
          size: 10,
          color: { theme: 1 },
          name: 'Arial',
          family: 2 },
       text: 'blah blah' },
     { font: { size: 10, color: { theme: 1 }, name: 'Arial', family: 2 },
       text: ' more blah blah blah \r\n' },
     { font:
        { bold: true,
          size: 10,
          color: { theme: 4 },
          name: 'Arial',
          family: 2 },
       text: '\r\nReference: numbers, blah blah blah' } ] }

The problem is when I write the .xlsx back into a file using workbook.xlsx.writeFile and open in Excel the file is prompted to be repaired, clearing only the cells with rich text, and I get an error (in Excel) of:
Repaired Records: String properties from /xl/sharedStrings.xml part (Strings)
Removed Records: Named range from /xl/workbook.xml part (Workbook)

A temporary solution I found was to just take the cell.value and set it equal to the cell.text which nukes the formatting while keeping the text, and everything works fine, but I was wondering if there was something wrong with the way rich text is being written back into a new file?

Thanks for any help or insight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions