//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; // Set data. worksheet.Range["A1:C3"].Value = new object[,] { {"BUDGET TOTALS", "ESTIMATED", "ACTUAL"}, {"Income", 63300, 57450}, {"Expenses", 54500, 49630} }; //Set style. worksheet.Range["B2:C3"].NumberFormat = "$#,##0"; worksheet.Columns[0].ColumnWidth = 17; worksheet.Columns[1].ColumnWidth = 13; worksheet.Columns[2].ColumnWidth = 10; worksheet.Range["A1:C3"].Borders[BordersIndex.InsideHorizontal].Color = System.Drawing.Color.White; worksheet.Range["A1:C3"].Borders[BordersIndex.InsideVertical].Color = System.Drawing.Color.White; worksheet.Range["A1:C1"].Interior.Color = System.Drawing.Color.FromArgb(255, 217, 102); worksheet.Range["A2:C3"].Interior.Color = System.Drawing.Color.FromArgb(237, 237, 237); //Create chart. GrapeCity.Documents.Excel.Drawing.IShape shape = worksheet.Shapes.AddChart(GrapeCity.Documents.Excel.Drawing.ChartType.ColumnClustered, 250, 0, 350, 250); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:C3"]); shape.Chart.ChartTitle.Text = "Estimated vs Actual"; //Display the data table. shape.Chart.HasDataTable = true; //Config the data table. GrapeCity.Documents.Excel.Drawing.IDataTable datatable = shape.Chart.DataTable; datatable.Format.Line.Color.ObjectThemeColor = ThemeColor.Accent6; datatable.Font.Color.ObjectThemeColor = ThemeColor.Accent2; datatable.Font.Size = 9; // Save to an excel file workbook.Save("ChartDataTable.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Set data. worksheet.Range("A1:C3").Value = New Object(,) { {"BUDGET TOTALS", "ESTIMATED", "ACTUAL"}, {"Income", 63300, 57450}, {"Expenses", 54500, 49630} } 'Set style. worksheet.Range("B2:C3").NumberFormat = "$#,##0" worksheet.Columns(0).ColumnWidth = 17 worksheet.Columns(1).ColumnWidth = 13 worksheet.Columns(2).ColumnWidth = 10 worksheet.Range("A1:C3").Borders(BordersIndex.InsideHorizontal).Color = System.Drawing.Color.White worksheet.Range("A1:C3").Borders(BordersIndex.InsideVertical).Color = System.Drawing.Color.White worksheet.Range("A1:C1").Interior.Color = System.Drawing.Color.FromArgb(255, 217, 102) worksheet.Range("A2:C3").Interior.Color = System.Drawing.Color.FromArgb(237, 237, 237) 'Create chart. Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 250, 0, 350, 250) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:C3")) shape.Chart.ChartTitle.Text = "Estimated vs Actual" 'Display the data table. shape.Chart.HasDataTable = True 'Config the data table. Dim datatable As IDataTable = shape.Chart.DataTable datatable.Format.Line.Color.ObjectThemeColor = ThemeColor.Accent6 datatable.Font.Color.ObjectThemeColor = ThemeColor.Accent2 datatable.Font.Size = 9 ' save to an excel file workbook.Save("ChartDataTable.xlsx")