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. Image for the cookie policy date

Create a Pi-Diagram on the first worksheet

Create a Pi-Diagram on the first worksheet ("workbook.Worksheets[0]").
 
foreach over all "Worksheets"

- new entry for the Pie-chart
- the name and values of the pie chart ("workbook.Worksheets[0]") should be build like this:
-> name of the current worksheet's name
-> value "the second column, and the sum between sheet[1, 2].Value and sheet[usedRange.LastRow, 2].Value")


end foreach

- the diagram should fill the entire viewport of "workbook.Worksheets[0]"

By the way which DLL's do I need ?

11 Replies

SS Sridhar Sukumar Syncfusion Team December 13, 2016 12:04 PM UTC

Hi, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared a sample for your requirement which can be downloaded from the following link 
 
 
If you want to view the chart in full worksheet, you can create a new chart sheet. Otherwise you can set the chart height and width based on your screen resolution by using ChartShape.Width and ChartShape.Height property to fill the chart in entire viewport of worksheet. 
 
Please refer the following UG Documentation link to know about the assemblies to be referenced in your application 
 
UG Documentation link: 
 
Please let us know if you have any concern. 
 
Regards, 
Sridhar S. 



MV mvxyc December 13, 2016 01:09 PM UTC

This is a nice beginning, but not exactly what  I need.

I need a single pie chart on the first worksheet("workbook.Worksheets[0];"),.

Each peace of the pie should be the sum of each worksheet's sum(- > "the second column, and the sum between sheet[1, 2].Value and sheet[usedRange.LastRow, 2].Value")") and the name for that peace of cake should its worksheet name(in the legend).

Please update your code.


SS Sridhar Sukumar Syncfusion Team December 14, 2016 07:21 AM UTC

Hi, 
 
Thank you for updating us. 
 
We have prepared a sample for your requirement which can be downloaded from the following link 
 
 
Please let us know if you have any concern. 
 
Regards, 
Sridhar S.  
  



TE Testname December 14, 2016 07:39 AM UTC

I get a "System.ArgumentOutOfRangeException", for Range, remember "workbook.Worksheets[0]" has no values for calculation...


TE Testname December 15, 2016 08:21 AM UTC

worksheet.UsedRange.LastRow
sheet.UsedRange.LastColumn

are sometimes "0". Don't know the reason for this.


SS Sridhar Sukumar Syncfusion Team December 15, 2016 12:25 PM UTC

Hi, 
 
Thank you for updating us. 
 
When the worksheet does not contain any value (data and styles), then the UsedRange.LastRow and UsedRange.LastColumn value will be 0. So, you can check whether the worksheet contains any value using WorksheetImpl.IsEmpty property before accessing LastRow and LastColumn property of used range which is illustrated in following code example.   
 
Code snippet: 
if (! (worksheet as WorksheetImpl).IsEmpty) 
{ 
range = worksheet.Range[1, 2, worksheet.UsedRange.LastRow, 2]; 
sheet.Range[i, column + 1].Value = worksheet.Name; 
sheet.Range[i, column + 2].Formula = "SUM(" + range.AddressGlobal + ")"; 
i++; 
} 
 
We have also modified the sample for your reference which can be downloaded from the following location 
 
 
Please let us know if you have any concern. 
 
Regards, 
Sridhar S. 



TE Testname December 15, 2016 02:02 PM UTC

Sorry, this did not work out.

worksheet.UsedRange.LastRow, is still 0 and I get that exeption...


TE Testname December 15, 2016 02:06 PM UTC

and taking a look at the file especially the sheet, it has the required data ... mmhh


TE Testname December 15, 2016 02:15 PM UTC

the first sheet is empty, because here should the chart drawed from the other sheets


TE Testname December 15, 2016 02:32 PM UTC

Ok, I solved that error.

I changed the charttype to "ExcelChartType.Bar_Stacked;".
How can I the scala(numbers in the chart, which show the amount).

How can I change it to "int" because now I have something like"0.5, 1, 1.5, 2 ,2.5...."


SS Sridhar Sukumar Syncfusion Team December 16, 2016 09:43 AM UTC

Hi,  
 
Thank you for updating us. 
 
You can achieve your requirement by assigning PrimaryValueAxis.MajorUnit property value. Please refer the following code example to achieve this. 
 
Code snippet: 
chart.PrimaryValueAxis.MajorUnit = 2; 
 
If you are still facing the issue, kindly share us the issue reproducing sample along with input files which will be helpful for us to give you a prompt solution at the earliest. 
 
Regards, 
Sridhar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon