to the file and download the file on button click.
Right now what i am doing is i have created a processor that copy the
template file and export data and makes it ready to download for the location.
template file and export data and makes it ready to download for the location.
But instead of running processor and having file copied and saved in different
location, I want to copy the template in memory and export the data in memory and response the stream out.
location, I want to copy the template in memory and export the data in memory and response the stream out.
Istudent RanaPosted Mar 14, 2018, 9:45 AM
I think i am missing a line of code here.
var myfile = HostingEnvironment.MapPath("~/DataFolder/MyExcelFile.xlsm");
var fileName = "MyExcelFile.xlsm";
var fileBytes = ExportExcel(myfile);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
{
var ms = new MemoryStream();
string xlReportSheet = ConfigurationManager.AppSettings["WorkSheetName_Report"];
DataTable dtDetails = GetDetails();
string xlDetailsSheet = ConfigurationManager.AppSettings["WorkSheetName_Details"];
{
if (dtNew.Rows.Count > 0)
{
ExportRecapDataNew(dtNew, xlReportSheet, xlPackage);
xlPackage.Save();
}
if (dtDetails.Rows.Count > 0)
{
ExportRecapDataRemodel(dtRemdl, xlDetailsSheet, xlPackage);
}
}
}
Leon DPosted Mar 13, 2018, 9:15 PM
Istudent RanaPosted Mar 13, 2018, 3:06 PM
var fileName = "MyExcelFile.xlsm";
var fileBytes = ExportExcel(myfile);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
{
var ms = new MemoryStream();
string xlReportSheet = ConfigurationManager.AppSettings["WorkSheetName_Report"];
DataTable dtDetails = GetDetails();
string xlDetailsSheet = ConfigurationManager.AppSettings["WorkSheetName_Details"];
{
if (dtNew.Rows.Count > 0)
{
ExportRecapDataNew(dtNew, xlReportSheet, xlPackage);
}
if (dtDetails.Rows.Count > 0)
{
ExportRecapDataRemodel(dtRemdl, xlDetailsSheet, xlPackage);
}
xlPackage.SaveAs(ms);
}
}
Debasis SahaPosted Mar 13, 2018, 2:59 PM