Export to MemoryStream problem
Posted: Thu Jun 08, 2017 11:23 am
Hi
could u please help me to export document to memorystream in asp.net mvc.
it cant export to MemoryStream but export directly to file or pdf is ok.
could u please help me to export document to memorystream in asp.net mvc.
it cant export to MemoryStream but export directly to file or pdf is ok.

Code: Select all
report.ExportDocument(StiExportFormat.ImageJpeg, stream, es);
Code: Select all
private MemoryStream report()
{
//log section
Stimulsoft.Report.StiLogService.LogEnabled = true;
StiLogService service1 = StiConfig.Services.GetService(typeof(StiLogService)) as StiLogService;
service1.LogPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Reports/Report.log"); // Path and filename
//read report section
StiReport report = new StiReport();
DataSet data = new DataSet();
report.Load(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Reports/TwoSimpleLists.mrt"));
data.ReadXml(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Data/Demo.xml"));
report.RegData(data);
//memorystream and render report section
MemoryStream stream = new System.IO.MemoryStream();
report.Render();
//ExportSetting and export section
StiJpegExportSettings es = new StiJpegExportSettings();
es.PageRange = new StiPagesRange(1);
report.ExportDocument(StiExportFormat.ImageJpeg, stream, es);
//Write memorystream to file which result is empty file
using (var fileStream = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Reports/abaw.bmp"), FileMode.Create, FileAccess.Write))
{
stream.CopyTo(fileStream);
}
return stream;
}