//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); object[,] data = new object[,] { {"Number", "Date", "Customer", "Description", "Trend", "0-30 Days", "30-60 Days", "60-90 Days", ">90 Days", "Amount"}, {"1001", new DateTime(2017, 5, 21), "Customer A", "Invoice 1001", null, 1200.15, 1916.18, 1105.23, 1806.53, null}, {"1002", new DateTime(2017, 3, 18), "Customer B", "Invoice 1002", null, 896.23, 1005.53, 1800.56, 1150.49, null}, {"1003", new DateTime(2017, 6, 15), "Customer C", "Invoice 1003", null, 827.63, 1009.23, 1869.23, 1002.56, null} }; IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["B2:K5"].Value = data; worksheet.Range["B:K"].ColumnWidth = 15; worksheet.Tables.Add(worksheet.Range["B2:K5"], true); worksheet.Tables[0].Columns[9].DataBodyRange.Formula = "=SUM(Table1[@[0-30 Days]:[>90 Days]])"; //create a new group of sparklines. worksheet.Range["F3"].SparklineGroups.Add(SparkType.Line, "G3:J3"); //create another new group of sparklines. worksheet.Range["F4:F5"].SparklineGroups.Add(SparkType.Column, "G4:J5"); //clear F3 and F4 cell's sparkline. F5 cell's sparkline still exist. worksheet.Range["F3, F4"].SparklineGroups.Clear();
' Create a new Workbook Dim workbook As New Workbook Dim data As Object(,) = { {"Number", "Date", "Customer", "Description", "Trend", "0-30 Days", "30-60 Days", "60-90 Days", ">90 Days", "Amount"}, {"1001", #5/21/2017#, "Customer A", "Invoice 1001", Nothing, 1200.15, 1916.18, 1105.23, 1806.53, Nothing}, {"1002", #3/18/2017#, "Customer B", "Invoice 1002", Nothing, 896.23, 1005.53, 1800.56, 1150.49, Nothing}, {"1003", #6/15/2017#, "Customer C", "Invoice 1003", Nothing, 827.63, 1009.23, 1869.23, 1002.56, Nothing} } Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("B2:K5").Value = data worksheet.Range("B:K").ColumnWidth = 15 worksheet.Tables.Add(worksheet.Range("B2:K5"), True) worksheet.Tables(0).Columns(9).DataBodyRange.Formula = "=SUM(Table1[@[0-30 Days]:[>90 Days]])" 'create a new group of sparklines. worksheet.Range!F3.SparklineGroups.Add(SparkType.Line, "G3:J3") 'create another new group of sparklines. worksheet.Range("F4:F5").SparklineGroups.Add(SparkType.Column, "G4:J5") 'clear F3 and F4 cell's sparkline. F5 cell's sparkline still exist. worksheet.Range("F3, F4").SparklineGroups.Clear() ' save to an excel file workbook.Save("ClearSparklines.xlsx")