C# 2008 aka C# 3.0Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
Sharing violation error while exporting an excel chart to an image
Hi all..i really need help here..
I build a windows application that can display an excel chart in a picture box, where the data to display the chart is coming from the sql db. The chart initially displayed in the excel file and i need to export the chart as an bmp image to the C://path, so that i can display it in the picture box of the windows form. This situation was successfully achieved only if try to display the chart (that already converted as bmp & displayed in the picture box) by clicking a button at the 1st time. The problem started when i try to display the chart again at the 2nd time. It throws the following exception :
A share violation has occurred. (Exception from HRESULT: 0x80030020 (STG_E_SHAREVIOLATION))
I think this problem appear when i try to export the chart as the image at the same path while its cannot overwrite that path.
Below is the snipped codes that i used in my program:
//display the chart
xRange = xlWorkSheet.get_Range("A1", "M3");
xChart.SetSourceData(xRange, misValue);
//export chart as picture file
xChart.Export(@"C:\excel_chart_export.bmp", "BMP", misValue);
//load picture to picturebox
pictureBox1.Image = new Bitmap(@"C:\excel_chart_export.bmp");
The error was highlighted on the export chart as picture file part..Can anyone please help me to overcome this..i really appreciate ur help..tq a lot..