fix undefined range for writeFile - test with ods #1914

Closed
jefleponot wants to merge 0 commits from master into master
jefleponot commented 2020-04-22 20:40:35 +00:00 (Migrated from github.com)
No description provided.
SheetJSDev commented 2020-04-22 21:39:27 +00:00 (Migrated from github.com)

This is probably a check that should appear in the ODS writer itself. Will LibreOffice or other tools handle an empty <table:table></table:table> tag?

This is probably a check that should appear in the ODS writer itself. Will LibreOffice or other tools handle an empty `<table:table></table:table>` tag?
jefleponot commented 2020-04-23 09:58:43 +00:00 (Migrated from github.com)

You are right correction doesn't fit LibreOffice behaviour. So I will propose another Fix :-)

LibreOffice Sheet with empty table : content.xml extract

<table:table table:name="test1_libreOffice" table:style-name="ta1">
    <table:table-column table:style-name="co1" table:default-cell-style-name="Default"/>
<table:table-row table:style-name="ro2">
<table:table-cell/>
</table:table-row>
</table:table>

LibreOffice Sheet with one element in table : content.xml extract

<table:table table:name="test2_libreOffice" table:style-name="ta1">
   <table:table-column table:style-name="co1" table:default-cell-style-name="ce1"/>
       <table:table-row table:style-name="ro1">
       <table:table-cell office:value-type="string" calcext:value-type="string">
           <text:p>merde</text:p>
       </table:table-cell>
    </table:table-row>
</table:table>

SheetJS writed file with my correction for an empty sheet :

<table:table table:name="test1_sheetJS_ods">
</table:table>

SheetJS writed file with my correction for an one cell sheet 👍

<table:table table:name="test2_sheetJS_ods">
     <table:table-row>
          <table:table-cell />
         <table:table-cell office:value-type="string"><text:p>TOIP</text:p></table:table-cell>
          <table:covered-table-cell/>
          <table:table-cell />
    </table:table-row>
</table:table>
You are right correction doesn't fit LibreOffice behaviour. So I will propose another Fix :-) LibreOffice Sheet with **empty** table : content.xml extract ``` <table:table table:name="test1_libreOffice" table:style-name="ta1"> <table:table-column table:style-name="co1" table:default-cell-style-name="Default"/> <table:table-row table:style-name="ro2"> <table:table-cell/> </table:table-row> </table:table> ``` LibreOffice Sheet with **one element** in table : content.xml extract ``` <table:table table:name="test2_libreOffice" table:style-name="ta1"> <table:table-column table:style-name="co1" table:default-cell-style-name="ce1"/> <table:table-row table:style-name="ro1"> <table:table-cell office:value-type="string" calcext:value-type="string"> <text:p>merde</text:p> </table:table-cell> </table:table-row> </table:table> ``` **SheetJS** writed file with my correction for an **empty** sheet : ``` <table:table table:name="test1_sheetJS_ods"> </table:table> ``` **SheetJS** writed file with my correction for an **one cell** sheet :+1: ``` <table:table table:name="test2_sheetJS_ods"> <table:table-row> <table:table-cell /> <table:table-cell office:value-type="string"><text:p>TOIP</text:p></table:table-cell> <table:covered-table-cell/> <table:table-cell /> </table:table-row> </table:table> ```
jefleponot commented 2020-04-23 10:11:17 +00:00 (Migrated from github.com)

This FIX

function decode_range(range) { var x = (range||"A1A1").split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }

Result :

    <table:table table:name="Schéma">
        <table:table-row>
          <table:table-cell />
        </table:table-row>
      </table:table>

Do you agree to accept a New Pull Request ?

This FIX > function decode_range(range) { var x = (range||**"A1A1"**).split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; } Result : ``` <table:table table:name="Schéma"> <table:table-row> <table:table-cell /> </table:table-row> </table:table> ``` Do you agree to accept a New Pull Request ?

Pull request closed

Sign in to join this conversation.
No description provided.