Excel export: manage cell text type

Excel export: manage cell text type

MaxggMaxgg Posts: 2Questions: 0Answers: 0

Description of problem

Hi, I would like to be able to manage "text" type cells. When I export it is very important that if the cell contains text the code recognizes it and sets the "text" type as the cell style. Currently when no specific pattern is recognized the cell is left with the "general"# type.

Proposal

  • change the var excelStrings: add in cellXfs tag this style:

'<xf numFmtId="49" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyFont="1" applyFill="1" applyBorder="1"/>'+

Case 1

  • if I want the type to always be "text".
  • in the addRow function in the else case change the code in:

`// String output - replace non standard characters for text output
var text = ! originalContent.replace ?
originalContent :
originalContent.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, '');

cell = _createNode( rels, 'c', {
    attr: {
        t: 'inlineStr',
        s: 68, // the 68 style is the new style type text
        r: cellId
    },
    children:{
        row: _createNode( rels, 'is', {
        children: {
            row: _createNode( rels, 't', {
                text: text,
                attr: {
                    'xml:space': 'preserve'
                }
            } )
        }
    } )
}

} );`

Case 2

  • if I want the "general" type instead of "text" or vice-versa, use the setting in columnDef to assign the correct type.
  • in the addRow function in the else case use this logic:
  1. check the columnDef to know whether to use the "general" or "text" type
  2. in case of "general" add the cell using the current code
  3. in case of "text" add the cell using the code proposed above
Sign In or Register to comment.