简体   繁体   English

以电子邮件身份发送RDLC作为正文

[英]Send RDLC in Email as Body

I Already Digging for 5 hours but nothing to found. 我已经挖了5个小时但没有找到。 Is there any way to generate the rdlc into HTML. 有没有办法将rdlc生成为HTML。 I tried RDLC to Image but my problem is, the generated image is slice in half. 我试过RDLC到Image,但我的问题是,生成的图像是切成两半。

Finally found solution(even though is not best answer). 终于找到了解决方案(即使不是最佳答案)。 So basically, convert first to Excel then convert the excel into html then read all the text. 所以基本上,首先转换为Excel然后将excel转换为html然后读取所有文本。 I use the FreeSprite.XLS to convert the excel into html. 我使用FreeSprite.XLS将excel转换为html。

Freespire.xls Link Freespire.xls链接

here is my code 这是我的代码

  private string GenerateHTMLReport(ReportViewer rv)
    {
        string mimeType,
            encoding,
            fileNameExtension;
        Warning[] warnings=null;
        string[] streamIds=null;

        //Export report
        byte[] exportBytes = rv.LocalReport.Render("Excel", null, out mimeType, out encoding,
            out fileNameExtension, out streamIds, out warnings);

        //convert to excel
        FileStream fs = new FileStream("report.xls", FileMode.Create);
        fs.Write(exportBytes, 0, exportBytes.Length);
        fs.Close();

        Workbook workbook = new Workbook();
        workbook.LoadFromFile("report.xls");

        //convert Excel to HTML  
        Worksheet sheet = workbook.Worksheets[0];
        sheet.SaveToHtml("report.html");

        string html =System.IO.File.ReadAllText("report.html");
        return "";
    }

generated HTML Code. 生成的HTML代码。 在此输入图像描述

generated HTML in Preview. 在预览中生成HTML。 在此输入图像描述

Hopefully someone will found it helpful. 希望有人会发现它有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM