public string Save([FromBody] SaveSettings saveSettings)
{
//return Workbook.Save(saveSettings);
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
try
{
// Convert Spreadsheet data as Stream
string basePath = Startup._env.ContentRootPath.ToString() + "/Files/Output.xlsx";
Stream fileStream = Workbook.Save<Stream>(saveSettings);
IWorkbook workbook = application.Workbooks.Open(fileStream);
var file = System.IO.File.Create(basePath);
fileStream.Seek(0, SeekOrigin.Begin);
fileStream.CopyTo(file); // to convert the stream to file options
file.Dispose();
fileStream.Dispose();
return "Spreadsheet saved in server";
}
catch (Exception ex)
{
return "Failure";
}
} |