This is a migrated thread and some comments may be shown as answers.

Rad chart export to xls or pdf or word doc

3 Answers 610 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
puneet
Top achievements
Rank 1
puneet asked on 16 Jan 2008, 02:04 AM
Hi,

I know rad chart doesn't provide any in-built way of exporting the rad chart to xls/pdf/doc formats. I was just wondering if there is any round about way of doing it?

thanks,
PM

3 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 18 Jan 2008, 08:18 AM
Hello Puneet,

You can use RadChart.Save() method to save the chart to an image or a memory stream. Then you can use it in any custom scenario.


Greetings,
Ves
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Abhay Das
Top achievements
Rank 1
answered on 22 Oct 2009, 04:38 PM
The problem with Rad Chart is you cannot print it into PDF directly.

Now, solution depends upon the third party tool or dll you use to make a PDF.

Since Rad chart is basically image being shown after rendering, you have to call the image using e.g. <asp:image runat="server" id="imgTest" ImageURL="Test.aspx" />.

Now in Test.aspx:

    public void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
                MemoryStream imageStream = drawChart();

                Byte[] imageContent = new Byte[imageStream.Length];

                imageStream.Position = 0;
                imageStream.Read(imageContent, 0, (Int32)imageStream.Length);
                imageStream.Close();

                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(imageContent);
        }
    }

    private MemoryStream drawChart()
    {
        RadChart chart = new RadChart();

        // Do the necessary coding in order to generate the chart.
        //If more than one chart  is being used call the same page with necessary inputs to generate a new image.

        MemoryStream mStream = new MemoryStream();

        chart.Save(mStream, ImageFormat.Jpeg);

        return mStream;
    }

I think it will solve the problem...if authentication issues doesn't arise.

0
Ves
Telerik team
answered on 27 Oct 2009, 08:19 AM
Hi Abhay Das,

Thanks for sharing this. I am sure it will prove handy for our community members. I have updated your Telerik points.

Best regards,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart (Obsolete)
Asked by
puneet
Top achievements
Rank 1
Answers by
Ves
Telerik team
Abhay Das
Top achievements
Rank 1
Share this question
or