C1Report - How do I render to pdf directly and make it appear as a download without going through C1

Posted by: rjnofuente on 10 September 2017, 11:35 am EST

  • Posted 10 September 2017, 11:35 am EST

    How do i render the report directly without passing through c1reportviewer just like the example you guys posted, but I want it to appear in a download dialog?



    privatevoid button1_Click(object sender, EventArgs e)
    {
    // create mail message
    MailMessage msg = new MailMessage(
    "from@from.com",
    "to@to.com",
    "Catalog Spreadsheet.",
    "Here's the spreadsheet I promised you.");

    // create attachment with spreadsheet
    MemoryStream stream = new MemoryStream();
    c1r.RenderToStream(stream, FileFormatEnum.Excel);
    stream.Position = 0;
    Attachment att = new Attachment(stream, "Catalog.xls", "application/x-excel");
    msg.Attachments.Add(att);

    // create another attachment or this won't work
    stream = new MemoryStream(Encoding.ASCII.GetBytes("This is some plain text"));
    msg.Attachments.Add(new Attachment(stream, "plain.txt"));

    // send message
    SmtpClient client = new SmtpClient("smtp.mymail.com");
    client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
    client.Send(msg);
    }

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels