|
public IActionResult Open(IFormCollection openRequest)
{
OpenRequest open = new OpenRequest();
open.File = openRequest.Files[0];
return Content(Workbook.Open(open));
}
public string Save(SaveSettings saveSettings)
{
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
//Convert Spreadsheet data as Stream
Stream fileStream = Workbook.Save<Stream>(saveSettings);
IWorkbook workbook = application.Workbooks.Open(fileStream);
FileStream filePath = new FileStream(Startup._env.WebRootPath.ToString() + "/Sample1.xlsx", FileMode.Create);
workbook.SaveAs(filePath); // you can use this stream as your need.
fileStream.Dispose();
filePath.Dispose();
return "Spreadsheet saved in server";
}
created() {
fetch("http://localhost:55367/" + "Sample1.xlsx").then(response => {
response.blob().then(fileBlob => {
var file = new File([fileBlob], "Sample.xlsx"); // to open the blob file
this.spreadsheetObj.open({ file: file });
});
});
}
|