How to use report.ExportToStream function in C#

…衆ロ難τιáo~ 提交于 2019-12-12 17:40:12

问题


I'm currently working in c#. I need to convert report file to pdf format and send it through mail. I wrote coding and its working. I use rpt.ExportToDisk(ExportFormatType) for conversion. But it takes long time. Can anyone please suggest me, how to use ExportToStream function, so that i can avoid former one as i dont want the report file to be stored in my disk. This is my code which is working

 rep1.Load(Server.MapPath("CrystalReport_ModbusNode.rpt"));
 rep1.ExportToDisk(ExportFormatType.PortableDocFormat,Server.MapPath("Modbus.pdf"));

I tried this:

rep1.ExportToStream(ExportFormatType.PortableDocFormat);
rep1.SaveAs(Server.MapPath("Modbus.pdf"));

But if I use this, Modbus.pdf is still in rpt format. ExportToStream id not doing any changes?? How can I send mail, without exporting it to my disk. Can anyone help me to solve this issue? Thanks in advance.


回答1:


The ExportToStream function returns a Stream. You can then use this stream to write a file. See this answer for details : How do I save a stream to a file in C#?



来源:https://stackoverflow.com/questions/14998750/how-to-use-report-exporttostream-function-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!