hhurz / tableExport.jquery.plugin

jQuery plugin to export a html table to JSON, XML, CSV, TSV, TXT, SQL, Word, Excel, PNG and PDF
MIT License
984 stars 714 forks source link

Export to Excel (xlsx) without hyperlinks #337

Closed rvaandrager closed 2 years ago

rvaandrager commented 2 years ago

It is currently possible to choose whether to export the text or the href of a hyperlink. In the Excel output, hyperlinks from the original data table are always shown as a hyperlink.

Is it possible to export only the text of hyperlinks in the original table, but without generating a hyperlink in the resulting Excel file?

Use case: I have a HTML table containing hyperlinks to other pages, but the urls are all relative to the current domain. Example: <a href="/my-link">Example link</a>. This will be rendered to =HYPERLINK("/my-link", "Example link") in the Excel sheet. That link will not work. I would like it to be 'Example link' only, so without the =HYPERLINK part.

hhurz commented 2 years ago

I assume you want to export to xlsx. If so, there is currently no way to omit the HYPERLINK. When exporting to the other Excel formats, there is the onCellHtmlHyperlink callback function that you could use. I will look into using this callback function for the xlsx export in the near future.

hhurz commented 2 years ago

With release version 1.20.2 there is a new xlsx callback function 'onHyperlink' which allows you to control the output of hyperlinks. See the test file xlsxHyperlink.html how to use this function. To be able to solve your issue, you should simply return the function parameter 'content' as a result in this function.

rvaandrager commented 2 years ago

Sorry for this late response. Thank you very much for the quick implementation of this new feature, this is exactly what I meant and it works like a charm :)