Value Override - not working #3022

Closed
opened 2023-10-30 15:12:46 +00:00 by sstorey-bma · 2 comments

Question: When parsing an HTML table like this to export to Excel, why is the data-v value ignored and an empty cell placed in the exported Excel workbook? The export runs BUT I expected as I had included the raw: false option that the cell parsing behavior would have been overridden (as per the example provided at this URL https://docs.sheetjs.com/docs/api/utilities/html#value-override)

HTML

<table id="myTable">
  <tr>
    <td class="align-text-top" data-t="n" data-v="0"></td>
  </tr>
</table>

JS

var tbl = document.getElementById("myTable");
var wb = XLSX.utils.table_to_book(tbl, {raw: false});
XLSX.writeFile(wb, "export.xlsb")

We are ultimately trying to export a table that contains input elements. It appears their values are ignored when exporting and only the string value inside the <td></td> is captured. Hence why we are trying to use the data-v value, we would like to set the data-v value with javascript when a user has edited an input element contained within the <td></td> element to work around the input element being ignored.

Any assistance / guidance you could offer would be greatly appreciated

Question: When parsing an HTML table like this to export to Excel, why is the data-v value ignored and an empty cell placed in the exported Excel workbook? The export runs BUT I expected as I had included the raw: false option that the cell parsing behavior would have been overridden (as per the example provided at this URL https://docs.sheetjs.com/docs/api/utilities/html#value-override) HTML ``` <table id="myTable"> <tr> <td class="align-text-top" data-t="n" data-v="0"></td> </tr> </table> ``` JS ``` var tbl = document.getElementById("myTable"); var wb = XLSX.utils.table_to_book(tbl, {raw: false}); XLSX.writeFile(wb, "export.xlsb") ``` We are ultimately trying to export a table that contains input elements. It appears their values are ignored when exporting and only the string value inside the \<td\>\</td\> is captured. Hence why we are trying to use the data-v value, we would like to set the data-v value with javascript when a user has edited an input element contained within the \<td\>\</td\> element to work around the input element being ignored. Any assistance / guidance you could offer would be greatly appreciated
Owner

The exact example in JSFiddle: https://jsfiddle.net/vLrj7ceg/

This appears to generate a XLSB file with cell A1 set to the numeric value 0.

Please confirm you are using the latest version (See https://docs.sheetjs.com/docs/getting-started/installation/ for more details).

The exact example in JSFiddle: https://jsfiddle.net/vLrj7ceg/ This appears to generate a XLSB file with cell A1 set to the numeric value 0. Please confirm you are using the latest version (See https://docs.sheetjs.com/docs/getting-started/installation/ for more details).
Author

The CDN was pinned to v0.15, after updating this to 0.20 (per your advice) this is resolved. Thank you.

The CDN was pinned to v0.15, after updating this to 0.20 (per your advice) this is resolved. Thank you.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3022
No description provided.