Other API Samples

Live SpreadsheetGear API Samples

Range Samples Operations Fill Data Series

Automatically fill cells with data.

// 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);
Run This Sample
Render Image

Generate an image representation of the results of this sample, which uses the SpreadsheetGear.Drawing.Image class to convert ranges, charts and shapes to images.


Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.


Supporting Files

The following files are utilized by this sample: