Excel export throwing error in MS excel
Excel export throwing error in MS excel

buttons: [ {
extend: 'excelHtml5',
title: '',
customize: function( xlsx ) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row c', sheet).each( function () {
if ( $('is t', this).text().indexOf("http") === 0 ) {
$(this).append('<f>' + 'HYPERLINK("'+$('is t', this).text()+'","'+$('is t', this).text()+'")'+ '</f>');
$(this).attr( 's', '2' );
}
});
}
} ],
I am trying to convert text to hyperlinks in excel so that they are clickable directly. These are image URLs from the table that get converted to plain text when i open the sheet. The above snippet throws an error in MS office.
It seems that my modification to the text to hyperlink has broken the parsing. Unsure why but it opens up fine in WPS and google sheets.
I have attached the excel that is causing an issue.
This discussion has been closed.
Answers
You've asked this once already - please don't repeat threads.
As I said in that thread:
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
@colin https://jsfiddle.net/j4czp5b0/4/
Sorry for the duplicate, I wasn't sure about the fiddle. Managed to replicate it now.
Please click on the export product button and you will notice the error while opening the file in MS excel. Comment that customize function and it works fine.
Yep, it's the
customize
function - it looks like you're trying to create links with the URLs. This thread should help, it's asking the same thing.Colin
@colin Since I want to add some custom data into the cell (in this case a URL) would
$(this).append('cell data to be replaced')
be correct ?? Because the .append() method inserts the specified content as the last child of the element. I followed some of the stuff posted on that thread but nothing is mentioned about replacing data in the cell.I would suggest using orthogonal data for that - so the data is exported with the appended information already. There's an example of that here.
Colin