//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:D16"].Value = new object[,] { {"Quarter", "Month", "Week", "Output"}, {"1st", "Jan", null, 3.5}, {null, "Feb", "Week1", 1.2}, {null, null, "Week2", 0.8}, {null, null, "Week3", 0.6}, {null, null, "Week4", 0.5}, {null, "Mar", null, 1.7 }, {"2st", "Apr", null, 1.1}, {null, "May", null, 0.8}, {null, "Jun", null, 0.3}, {"3st", "July", null, 0.7}, {null, "Aug", null, 0.6}, {null, "Sept", null, 0.1}, {"4st", "Oct", null, 0.5}, {null, "Nov", null, 0.4}, {null, "Dec", null, 0.3}, }; //Create a treemap chart. IShape shape = worksheet.Shapes.AddChart(ChartType.Treemap, 300, 20, 300, 200); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D16"]); //Set the parent data labels are displayed as banners. shape.Chart.SeriesCollection[0].ParentDataLabelOption = ParentDataLabelOptions.Banner; //Modify chart title text. shape.Chart.ChartTitle.Text = "Annual Report"; // Save to an excel file workbook.Save("AddTreeMapChart.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("A1:D16").Value = New Object(,) { {"Quarter", "Month", "Week", "Output"}, {"1st", "Jan", Nothing, 3.5}, {Nothing, "Feb", "Week1", 1.2}, {Nothing, Nothing, "Week2", 0.8}, {Nothing, Nothing, "Week3", 0.6}, {Nothing, Nothing, "Week4", 0.5}, {Nothing, "Mar", Nothing, 1.7}, {"2st", "Apr", Nothing, 1.1}, {Nothing, "May", Nothing, 0.8}, {Nothing, "Jun", Nothing, 0.3}, {"3st", "July", Nothing, 0.7}, {Nothing, "Aug", Nothing, 0.6}, {Nothing, "Sept", Nothing, 0.1}, {"4st", "Oct", Nothing, 0.5}, {Nothing, "Nov", Nothing, 0.4}, {Nothing, "Dec", Nothing, 0.3} } 'Create a treemap chart. Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.Treemap, 300, 20, 300, 200) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:D16")) 'Set the parent data labels are displayed as banners. shape.Chart.SeriesCollection(0).ParentDataLabelOption = Drawing.ParentDataLabelOptions.Banner 'Modify chart title text. shape.Chart.ChartTitle.Text = "Annual Report" ' save to an excel file workbook.Save("AddTreeMapChart.xlsx")