tableExport.jquery.plugin
tableExport.jquery.plugin copied to clipboard
Need option for fileName to be saved
When i download the file the file name is in encoded form. I dont want it to be encoded. I need to enter the filename manually or during intialisation
I'd like to second asking for this!
Hi
Greetings!! I found the answer....
Try This….
Html:
Initialization (Jquery):
$(".excel").click(function () { $(".table").dataTable().fnDestroy(); $('#datatable').tableExport({ type: 'excel', escape: 'false', tableName: 'ResolutionReport'
});
In tableExporter.js var base64data = "base64," + $.base64.encode(excelFile); // window.open('data:application/vnd.ms-'+defaults.type+';filename=exportData.doc;' + base64data); Instead of this add below lines
document.getElementById("dlink").href = 'data:application/vnd.ms-' + defaults.type + ';filename=exportData.doc;' + base64data; document.getElementById("dlink").download = defaults.tableName.toString() + '.xls'; document.getElementById("dlink").click();
Thanks,
Regards, Nivetha Rajendran.
From: Janet [mailto:[email protected]] Sent: Wednesday, November 05, 2014 8:45 PM To: kayalshri/tableExport.jquery.plugin Cc: Nivetha Rajendran Subject: Re: [tableExport.jquery.plugin] Need option for fileName to be saved (#13)
I'd like to second asking for this!
— Reply to this email directly or view it on GitHubhttps://github.com/kayalshri/tableExport.jquery.plugin/issues/13#issuecomment-61821930.
[Aspire Systems]
This e-mail message and any attachments are for the sole use of the intended recipient(s) and may contain proprietary, confidential, trade secret or privileged information. Any unauthorized review, use, disclosure or distribution is prohibited and may be a violation of law. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
The last line: document.getElementById("dlink").click(); makes the dialog appears twice. Had to comment it out. All the same, thanks a million. :)
Thanks for this workaround. From the example on the main page to this workaround I just had to add the link to the page and then it worked.
So my html looked like this (a snipped of it anyway)
<a id="dlink" style="display: none;"></a>
<div class="btn-group">
<button class="btn btn-warning btn-sm" id="exportButton">Export table</button>
</div>
And in my js file I did leave in the .click(); line as well
Hi! Just change
window.open('data:application/vnd.ms-'+defaults.type+';filename=exportData.doc;' + base64data);
to
$('<a style="display:none" href="data:application/vnd.ms-'+defaults.type+';filename=exportData.doc;'+base64data+'" download="'+defaults.tableName.toString()+'.xls"><span></span></a>').appendTo(document.body).find('span').trigger("click").parent().remove();
in tableExport.jquery.json will solve the problem
thanks for all the answers
Please help me i could not download excel sheet in particular file name
function fillHidTable(){ var htqf; //-- hidden field var rf; //-- retrieved field for ( var i = 0; i < counter+1; i++ ) { rf = "htqf"+i; rf2 = "Testset"+i; rf3 = "NoT"+i; rf4="Sysid"+i; document.getElementById(rf).innerHTML = document.getElementById("QCALC"+i).value; document.getElementById(rf3).innerHTML =x[i].getElementsByTagName("Number_Of_TestCases")[0].childNodes[0].nodeValue document.getElementById(rf2).innerHTML =x[i].getElementsByTagName("TestCaseName")[0].childNodes[0].nodeValue document.getElementById(rf4).innerHTML = document.getElementById("systemid"+i).value; } tableToExcel('hidTable', 'Automation Plan','myfile.xls'); } var tableToExcel = (function() { var uri = 'data:application/vnd.ms-excel;base64,' , template = '
return function(table, name, filename) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
document.getElementById("hidTable").href = uri + base64(format(template, ctx));
document.getElementById("hidTable").download = filename;
}
})()
here are my table details
input type="button" onclick="fillHidTable();" value="Export Data to Excel"
div id="hidTable" style="display: none"
table id="testTable"