I am currently using Aspose.Cells to generate an Excel file.
However, I am facing some difficulties in saving the xls file on the disk. Below is a snippet of my get method:
[Route("xls")]
[HttpGet]
public HttpResponseMessage Export()
{
try
{
string dataDir = KnownFolders.GetPath(KnownFolder.Downloads);
//var workbook = TransferService.Export(); //TODO get xml
Workbook workbook = new Workbook();
var stream = workbook.SaveToStream();
// I need save this workbook
return Request.CreateResponse(HttpStatusCode.OK); //it's not important here
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError); //it's not important here
}
}
In addition, I have a function that is triggered onClick:
function exportToXls() {
$.get(exportURI, function (response) {
return response;
});
}
My goal is for the user to be able to click on a button and have the file saved to their disk or prompt them with a browser window to choose the location and name. Any suggestions on how to achieve this?