export excel keeping the original links
export excel keeping the original links
rafaelrmontes
Posts: 16Questions: 3Answers: 0
Hi,
I wonder if the excel export button can bring the original format of the table such as links?
Thank you
This question has an accepted answers - jump to answer
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Actually, I can answer that one immediately. Currently no - the Excel export does not attempt to keep links, sorry. There are two barriers to this:
stripHtml
option for the export optionscustomize
callback for the export button to create the XML structure needed for the links. You'd need to refer to the open spreadsheet specification for what that XML structure is.Allan
Thank you Allan, I will then need to do the translation, if a tag with the link is found then build the xml structure that represent from the excel side, how do I customize the callback?
Thank you!
The
customize
callback of theexcelHtml5
button type is where you can modify the XML generated. There is a basic example of how it can be used here.Allan
Thank you, by any chance do you know where can I find documentation about what attributes should be find or set related to links?
Thank you
I found the way to create the hyperlink, but now I need to know how can I identify how I can read the html tag with tag of hyperlink and read the text and the link in the href, currently we can read the text but not the href content, how can I do that?
Hello Allan,
I can't find the way to read hyperlink from the datatable, the data is presented as href html tag, I can get the text but not the value of href as I mentioned before, any advice on this?
Perhaps a formatting function would be best here. That will give you access to the original
td
cell in the table, from which you can read the livea
element and itshref
attribute. Then later on in yourcustomize
callback you can use the data returned from that function to populate your link.Allan
Hi Allan,
thank you for the link, I can see how to give format to the table, but the problem is how can I read the source table in html, currently I'm stuck on trying to read the property href, looping all cells and when I get into the cell the only value I can get is the text by doing $(this).text() but there is no $(this).href() which is something I'm looking for,
Thank you and happy new year.
Maybe this SO thread will help you get the href attribute. If you still need help the best thing to do is to build a simple test case showing what you have so we can provide more specific answers.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hi Kthorngren,
I haven't found information about how to read the href value.
Thank you.
Are you trying with `jQuery attr() or jQuery prop() as shown in the SO thread?
Its possible the selector you are using is not the
a
element. You will need to useattr()
orprop()
on thea
element. In your example above you have$(this).text()
. Isthis
thea
element?Its impossible for us to help further without seeing what you have and what you are trying to do. PLEASE provide a simple test case showing what you have and are trying so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin