Other API Samples C# logo

Fill Data Series SpreadsheetGear API Sample

Description

Automatically fill cells with data.

Source Code

// Create a new workbook and get a reference to the active sheet and its cells.
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(@"DataSeries.xlsx");
SpreadsheetGear.IWorksheet worksheet = workbook.ActiveWorksheet;
SpreadsheetGear.IRange cells = worksheet.Cells;

// Auto fill by month name.
cells["A2:A13"].DataSeries(true,
    SpreadsheetGear.DataSeriesType.AutoFill,
    SpreadsheetGear.DataSeriesDate.Day, 1, 1, false);

// Fill by day.
cells["B2:B13"].DataSeries(true,
    SpreadsheetGear.DataSeriesType.Chronological,
    SpreadsheetGear.DataSeriesDate.Day, 1, System.Double.MaxValue, false);

// Fill by month.
cells["C2:C13"].DataSeries(true,
    SpreadsheetGear.DataSeriesType.Chronological,
    SpreadsheetGear.DataSeriesDate.Month, 1, System.Double.MaxValue, false);

// Fill by year.
cells["D2:D13"].DataSeries(true,
    SpreadsheetGear.DataSeriesType.Chronological,
    SpreadsheetGear.DataSeriesDate.Year, 1, System.Double.MaxValue, false);

// Fill linear.
cells["E2:E13"].DataSeries(true,
    SpreadsheetGear.DataSeriesType.DataSeriesLinear,
    SpreadsheetGear.DataSeriesDate.Day, 1, System.Double.MaxValue, false);

// Fill linear trend.
cells["F2:F13"].DataSeries(true,
    SpreadsheetGear.DataSeriesType.DataSeriesLinear,
    SpreadsheetGear.DataSeriesDate.Day, 1, 1, true);