linways/table-to-excel

How to add hyperlink?

HelenDias opened this issue · 4 comments

Hi!
Anyone can help me?
I have a HTML with my table and I'm using style classes in td and/or tr. I need to add a hyperlink on cell, but I don't find how to do that.
Also, I will like to add more than one hyperlink at the same cell (td).
Anyone have any example to help me?

Added support for hyperlink with the latest version of SheetJS. Download latest version of linways/table-to-excel
use data-link to specify the url.
Eg:

<td data-link="https://google.com">
	<a href="https://google.com">Hyperlink</a>
</td>

Instead of using dist/xlsx_html.full.min.js, include latest version of SheetJS/js-xlsx along with dist/xlsx_html_utils.min.js and lib/FileSaver.min.js.

<script type="text/javascript" src="lib/FileSaver.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/SheetJS/js-xlsx/master/dist/xlsx.core.min.js"></script>
<script type="text/javascript" src="dist/xlsx_html_utils.min.js"></script>

Note that the styles will not work with the original version of SheetJS/js-xlsx.
I will try to add hyperlink support to protobi/js-xlsx so that styles will work along with hyperlinks.

@rohithb,

Is there a fork available of protobi/js-xlsx that this module could use to support styles and links?

@gavinhungry protobi/js-xlsx is not actively maintained, and I searched for its fork, unfortunately I couldn't find any.
So I'm re-writting the library to use guyonroche/exceljs as the backend, which supports hyperlinks, images and more. Its available under branch v2.

All the exsiting features are migrated and added support for hyperlink.
You can use data-hyperlink to add hyperlink to a cell.

I had to change the function name to TableToExcel.convert, since we no longer use js-xlsx.
The readme is not complete yet. Please refer this if required.

Released v1.0.0
Change the backend excel library.
Added support for hyperlink, border colors, exclude rows etc.