I am using Web API 4.5.1. I am generating API in C# code and passing this API to front end, where the front end is built on HTML and AngularJS JavaScript. My requirement is to create an API for export to Excel to the front end. I am a kind of stuck here. I am receiving request from front end people with fromdate and todate. Based on that I will query the database to get the data and if I am successful, get the HTML format out of it. I am unable to go further as I am new to this. Below is the code which I am trying to achieve this with:
[HttpPost]
public HttpResponseMessage ExportToExcel(string fromTimeStamp, string toTimeStamp)
{
DateTime fromDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
fromDate = fromDate.AddMilliseconds(Convert.ToDouble(fromTimeStamp)).ToLocalTime();
fromDate.AddDays(1);
DateTime toDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
toDate = toDate.AddMilliseconds(Convert.ToDouble(toTimeStamp)).ToLocalTime();
toDate.AddDays(1);
var fromDate1 = fromDate.AddDays(1).ToString("yyyy-MM-dd");
var toDate1 = toDate.AddDays(1).ToString("yyyy-MM-dd");
var bal = new AdminBAL();
var ExportData = bal.ExportToExcel(fromDate1, toDate1);
//where Exportdata is the html format for the data required.
// unable to find the solution here
}
How can I complete this operation?