Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
|
C# 2008 aka C# 3.0 Discuss 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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2009, 12:07 AM
Registered User
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy 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:

Excel.Range xRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type. Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 300);
Excel.Chart xChart = myChart.Chart;

//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..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Received sharing violation occur on .php file Snowby Pro PHP 0 April 9th, 2008 08:18 AM
dll error while exporting to Excel lily611 General .NET 2 June 14th, 2005 11:43 PM
Exporting chart to gif in asp.net spacy General .NET 1 April 11th, 2005 05:49 AM
Exporting/Importing error to EXCEL haasf Access 1 December 4th, 2003 09:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.