How to Create a pie chart using gembox presentation code

I am using Gembox to create a project where i will be adding some data to a pie chart and create ppt out of it in c#. In the documentation they have not provided any sample for pie chart but they have provided for bar chart based on which I have created a code but getting some error can anyone please help me on this topci

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> using GemBox.Presentation;
using spreedsheetCharts = GemBox.Spreadsheet.Charts;
using spreedsheet = GemBox.Spreadsheet;
// Add new PowerPoint presentation slide.
// If using the Professional version, put your GemBox.Presentation serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// If using the Professional version, put your GemBox.Spreadsheet serial key below.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
var firstLastSlidesPresentation= new PresentationDocument();
var slide = firstLastSlidesPresentation.Slides.AddNew(SlideLayoutType.Custom);
// Add simple PowerPoint presentation title.
var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle,
116.8, 20, 105, 10, GemBox.Presentation.LengthUnit.Millimeter);
textBox.AddParagraph().AddRun("New presentation with chart element.");
// Create PowerPoint chart and add it to slide.
var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Bar,
49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter);
// Get underlying Excel chart.
spreedsheetCharts.ExcelChart excelChart = (spreedsheetCharts.ExcelChart)chart.ExcelChart;
spreedsheet.ExcelWorksheet worksheet = excelChart.Worksheet;
// Add data for Excel chart.
worksheet.Cells["A1"].Value = "Name";
worksheet.Cells["A2"].Value = "John Doe";
worksheet.Cells["A3"].Value = "Fred Nurk";
worksheet.Cells["A4"].Value = "Hans Meier";
worksheet.Cells["A5"].Value = "Ivan Horvat";
worksheet.Cells["B1"].Value = "Salary";
worksheet.Cells["B2"].Value = 3600;
worksheet.Cells["B3"].Value = 2580;
worksheet.Cells["B4"].Value = 3200;
worksheet.Cells["B5"].Value = 4100;
// Select data.
excelChart.SelectData(worksheet.Cells.GetSubrange("A1:B5"), true);
firstLastSlidesPresentation.save("somename.pptx")
</code>
<code> using GemBox.Presentation; using spreedsheetCharts = GemBox.Spreadsheet.Charts; using spreedsheet = GemBox.Spreadsheet; // Add new PowerPoint presentation slide. // If using the Professional version, put your GemBox.Presentation serial key below. ComponentInfo.SetLicense("FREE-LIMITED-KEY"); // If using the Professional version, put your GemBox.Spreadsheet serial key below. SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); var firstLastSlidesPresentation= new PresentationDocument(); var slide = firstLastSlidesPresentation.Slides.AddNew(SlideLayoutType.Custom); // Add simple PowerPoint presentation title. var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 116.8, 20, 105, 10, GemBox.Presentation.LengthUnit.Millimeter); textBox.AddParagraph().AddRun("New presentation with chart element."); // Create PowerPoint chart and add it to slide. var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Bar, 49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter); // Get underlying Excel chart. spreedsheetCharts.ExcelChart excelChart = (spreedsheetCharts.ExcelChart)chart.ExcelChart; spreedsheet.ExcelWorksheet worksheet = excelChart.Worksheet; // Add data for Excel chart. worksheet.Cells["A1"].Value = "Name"; worksheet.Cells["A2"].Value = "John Doe"; worksheet.Cells["A3"].Value = "Fred Nurk"; worksheet.Cells["A4"].Value = "Hans Meier"; worksheet.Cells["A5"].Value = "Ivan Horvat"; worksheet.Cells["B1"].Value = "Salary"; worksheet.Cells["B2"].Value = 3600; worksheet.Cells["B3"].Value = 2580; worksheet.Cells["B4"].Value = 3200; worksheet.Cells["B5"].Value = 4100; // Select data. excelChart.SelectData(worksheet.Cells.GetSubrange("A1:B5"), true); firstLastSlidesPresentation.save("somename.pptx") </code>
 using GemBox.Presentation;
 using spreedsheetCharts =  GemBox.Spreadsheet.Charts;
 using spreedsheet =  GemBox.Spreadsheet;

 // Add new PowerPoint presentation slide.
 // If using the Professional version, put your GemBox.Presentation serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");

// If using the Professional version, put your GemBox.Spreadsheet serial key below.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

    var firstLastSlidesPresentation= new PresentationDocument();

    var slide = firstLastSlidesPresentation.Slides.AddNew(SlideLayoutType.Custom);

    // Add simple PowerPoint presentation title.
    var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle,
        116.8, 20, 105, 10, GemBox.Presentation.LengthUnit.Millimeter);

    textBox.AddParagraph().AddRun("New presentation with chart element.");

    // Create PowerPoint chart and add it to slide.
    var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Bar,
        49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter);

    // Get underlying Excel chart.
    spreedsheetCharts.ExcelChart excelChart = (spreedsheetCharts.ExcelChart)chart.ExcelChart;
    spreedsheet.ExcelWorksheet worksheet = excelChart.Worksheet;

    // Add data for Excel chart.
    worksheet.Cells["A1"].Value = "Name";
    worksheet.Cells["A2"].Value = "John Doe";
    worksheet.Cells["A3"].Value = "Fred Nurk";
    worksheet.Cells["A4"].Value = "Hans Meier";
    worksheet.Cells["A5"].Value = "Ivan Horvat";

    worksheet.Cells["B1"].Value = "Salary";
    worksheet.Cells["B2"].Value = 3600;
    worksheet.Cells["B3"].Value = 2580;
    worksheet.Cells["B4"].Value = 3200;
    worksheet.Cells["B5"].Value = 4100;

    // Select data.
    excelChart.SelectData(worksheet.Cells.GetSubrange("A1:B5"), true);
    
    firstLastSlidesPresentation.save("somename.pptx")

error –

‘ExcelChart’ does not contain a definition for ‘Worksheet’ and no accessible extension method ‘Worksheet’ accepting a first argument of type ‘ExcelChart’ could be found (are you missing a using directive or an assembly reference?)

I tried to find many places where i can get a code for this issue but there is no solution and also the gembox documentation is not clear on this the code i used is almost identical to the bar chart.

New contributor

Tejas Shaha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật