Hi piofenton
Same problem here, but I got a little farther (still can't get it to work, though, but maybe you'll have better luck).
There are two ways I found to get the chart as an image:
1. Once your chart is generated, you can copy the image of it to the clipboard, and then save the contents of the clipboard to an image file.
Code:
System.Drawing.Image tempImage=null;
//copy image to clipboard
ExcelChartObject.Chart.CopyPicture ( XlPictureAppearance.xlScreen,
XlCopyPictureFormat.xlBitmap,
XlPictureAppearance.xlScreen );
if (Clipboard.GetDataObject() != null)
{
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent (DataFormats.Bitmap ))
{
tempImage = (Bitmap) data.GetData (DataFormats.Bitmap );
// save image to file
tempImage.Save (ImageFileName);
}
}
// ExcelChartImage is the Image cont5rol on the web form. Assign the URL to the imagefile we just saved
ExcelChartImage.ImageUrl = ImageFileName;
2. Export the chart's image directly to a file
Code:
ExcelChart.Export (ImageFileName, "GIF", false);
On my end, I have tried both methods, as well as trying to use Microsoft Excel Chart 10 (and 11). All three attempts failed miserably. The first two fail with a wierd exception as soon as I try to do anything with the chart object (in a server app only; standalone app is fine). I've raised thread732-1289097, but so far no answers
And the COM option fails because after I put it on my form (again, web form only. Standalone is fine), the control has no ID (I have to assign one manually) and double clicking on it does not take me to the code. Even if I try typing the control ID and a period, intellisense does not pick up its methods and properties. Compiling just results in an error.
I think there's something off with my web projects, but cannot for the life of me figure it out. I do have Office 2003 installed, so I don't think it's licensing. But you never know ...
I hope you have better luck.