export excel keeping the original links

export excel keeping the original links

rafaelrmontesrafaelrmontes Posts: 10Questions: 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

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    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

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    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:

    • We strip HTML by default (that can be disabled with the stripHtml option for the export options
    • You'd need to use the customize 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

  • rafaelrmontesrafaelrmontes Posts: 10Questions: 3Answers: 0

    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!

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    The customize callback of the excelHtml5 button type is where you can modify the XML generated. There is a basic example of how it can be used here.

    Allan

  • rafaelrmontesrafaelrmontes Posts: 10Questions: 3Answers: 0

    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

  • rafaelrmontesrafaelrmontes Posts: 10Questions: 3Answers: 0

    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?

  • rafaelrmontesrafaelrmontes Posts: 10Questions: 3Answers: 0

    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?

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    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 live a element and its href attribute. Then later on in your customize callback you can use the data returned from that function to populate your link.

    Allan

  • rafaelrmontesrafaelrmontes Posts: 10Questions: 3Answers: 0

    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.

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    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

  • rafaelrmontesrafaelrmontes Posts: 10Questions: 3Answers: 0

    Hi Kthorngren,
    I haven't found information about how to read the href value.
    Thank you.

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    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 use attr() or prop() on the a element. In your example above you have $(this).text(). Is this the a 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

Sign In or Register to comment.