We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





44168 May 16,2006 06:52 AM UTC Jun 7,2006 11:38 AM UTC ASP.NET Web Forms (Classic) 1
Tags: XlsIO
Asked On May 16, 2006 06:52 AM UTC

Im having trouble trying to get a chart to appear on an existing worksheet in one of my templates. The code is below. Everything executes without error, but no chart appears. I have tried using Workbook.Charts.Add("Residuals") instead of line 3 below, but this throws a ''worksheet already exists'' type error. All I want to do is create and display a chart on an existing worksheet - can anybody show me how to do this ? IWorksheet chartSheet = Workbook.Worksheets["Residuals"]; IRange residualChartRange = chartSheet.Range[RESIDUALS_CHART]; IChart residualChart = chartSheet.Charts.Add(); residualChart.ChartType = ExcelChartType.Bar_Clustered; residualChart.XPos = 72; residualChart.YPos = 72; residualChart.DataRange = chartSheet.Range[RESIDUALS_DATA]; residualChart.IsSeriesInRows = true;

Administrator [Syncfusion]
Replied On June 7, 2006 11:38 AM UTC

Hi Roy, Sorry for the long delay in getting back to you. I am not sure if I understand your requirements correctly. However 1) To preserve the chart properties in the template worksheet please use the following code : IWorkbook workbook = application.Workbooks.Open(@"..\..\Data\ChartsTemplate.xls",ExcelParseOptions.DoNotParseCharts); Here is a sample which does this:ChartsTemplate.zip 2) If you need to add a chart sheet to a template document please use the following peace of code: //Adding a New(Embedded chart) to the Worksheet IChartShape shape = sheet.Charts.Add(); shape.DataRange = sheet.Range["B3:D6"]; Here is a sample for your reference:Embedded_Charts.zip Regarding the "Worksheet already exists" Exception. This will be thrown only when adding a worksheet with the same name as a already existing worksheet. Please take a look at the samples and let me know if you have any queries. BestRegards, Bharath


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon