TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sonasri Tripathy
NA
6
816
How to give a specific name of expert to excel
Apr 29 2017 4:01 AM
I have a jquerry function to make expert to excel and it is working also but when i download it saved in a name like Download,Download(1) as on. But i want to give a specific name of it as consolidated report
Bellow is my code:
Sys.Application.add_load(function () {
$('[id*=img_export]').on('click', function () {
ExportToExcel('grdConsolidated');
location.reload();
});
});
function ExportToExcel(Id) {
var msg = $('[id*=lblmsg]').text();
// alert(msg);
var tab_text = "<table border='2px'><tr rowspan='2'><td colspan='16' style='font-size:14.0pt; font-family:Calibri; background:LightCoral; text-align:center;'>" + msg + "</td></tr><tr style='background:BurlyWood;'>";
var textRange;
var j = 0;
tab = document.getElementById(Id);
var headerRow = $('[id*=grdConsolidated] tr:first');
tab_text += headerRow.html() + '</tr><tr>';
var rows = $('[id*=grdConsolidated] tr:not(:has(th))');
for (j = 0; j < rows.length; j++) {
if ($(rows[j]).css('display') != 'none') {
tab_text = tab_text + rows[j].innerHTML + "</tr>";
}
}
tab_text = tab_text + "</table>";
tab_text = tab_text.replace(/<A[^>]*>|<\/A>/g, ""); //remove if u want links in your table
tab_text = tab_text.replace(/<img[^>]*>/gi, ""); // remove if u want images in your table
tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer
{
txtArea1.document.open("txt/html", "replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
sa = txtArea1.document.execCommand("SaveAs", true, Id + "ConsolidatedReport.xls");
}
else { //other browser not tested on IE 11
sa = window.open('data:application/ConsolidatedReport.ms-excel,' + encodeURIComponent(tab_text));
}
return (sa);
}
Reply
Answers (
2
)
dropdown validation...........
how integrate Unite Gallery into ASP.NET with C#