如何在C#中使用report.ExportToStream函数 [英] How to use report.ExportToStream function in C#

查看:303
本文介绍了如何在C#中使用report.ExportToStream函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用c#。我需要将报告文件转换为pdf格式并通过邮件发送。我写了编码及其工作。我使用 rpt.ExportToDisk(ExportFormatType) 进行转换。但是需要很长时间。任何人都可以建议我,如何使用 ExportToStream 函数,这样我就可以避免使用前一个,因为我不希望将报告文件存储在其中我的磁盘。
这是我的代码,正在运行

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"));

我尝试过:

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

但是如果使用此功能, Modbus.pdf 仍位于 rpt 格式。
ExportToStream id没有做任何更改?
如何发送邮件,而不将其导出到磁盘。谁能帮我解决这个问题?

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.

推荐答案

ExportToStream函数返回一个Stream。然后,您可以使用此流来写入文件。
有关详细信息,请参见此答案:如何保存流到C#中的文件?

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#?

这篇关于如何在C#中使用report.ExportToStream函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆