tableExport.jquery.plugin icon indicating copy to clipboard operation
tableExport.jquery.plugin copied to clipboard

Need option for fileName to be saved

Open Nivethar92 opened this issue 9 years ago • 7 comments

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

Nivethar92 avatar Oct 07 '14 05:10 Nivethar92

I'd like to second asking for this!

Muzical84 avatar Nov 05 '14 15:11 Muzical84

Hi

Greetings!! I found the answer....

Try This….

Html:

ExcelDownload

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.

Nivethar92 avatar Nov 06 '14 03:11 Nivethar92

The last line: document.getElementById("dlink").click(); makes the dialog appears twice. Had to comment it out. All the same, thanks a million. :)

Adomovic avatar Nov 12 '14 10:11 Adomovic

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

rootedsoftware avatar Nov 13 '14 20:11 rootedsoftware

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

nsemikov avatar Mar 24 '15 19:03 nsemikov

thanks for all the answers

serkanince avatar Jun 25 '15 11:06 serkanince

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 = '

{table}
' , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) } , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
       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"

MarappPrashanth avatar Dec 29 '16 13:12 MarappPrashanth