In need of some advice here.
I have written a ASP.NET webpage to display a report. The rendered html table was done in the server side and passed back to the calling AJAX as a string:
public string GenerateHtml()
{
var html = "";
html = "<table><tr><td></td></tr></table>";
return html;
}
and the calling AJAX:
$.ajax({
url: '/BoardTransaction/GenerateHtml',
type: "GET",
},
async: false,
success: function (result) {
$('#divReport').html(result);
}
});
and in the page I have a button that downloads the generated table to Excel:
$("#btnDownload").click(function (e) {
var file = new Blob([$('#divReport').html()],{ type: "application/vnd.ms-excel" });
var fileName = "FORECAST_" + jQueryToday() + ".xls";
var url = URL.createObjectURL(file);
var a = $("<a />",
{
href: url,
download: fileName
})
.appendTo("body")
.get(0)
.click();
e.preventDefault();
});
Now another of the requirement is that to have a scheduler to download the same table and e-mail them once a week. I've done coding to Excel before so I knew it would be a pain to write GenerateHtml() to suit the coding needed to generate Excel file so I was wondering if I could just basically copy the same function into my console app and use the html strings to generate Excel.
Hope if you could give any suggestions on where should I start. Tried searching html to excel but the results gave me if it is in ASP.NET but not concole app.
Thank you for your kind attention.