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.
Unfortunately, activation email could not send to your email. Please try again.

Charts

Thread ID:

Created:

Updated:

Platform:

Replies:

44168 May 16,2006 02:52 AM Jun 7,2006 07:38 AM ASP.NET Web Forms (Classic) 1
loading
Tags: XlsIO
Roy
Asked On May 16, 2006 02:52 AM

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 07:38 AM

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

CONFIRMATION

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.

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.

;