Excel

Targeting Ranges and Cells

WithRange sets an A1-notation range (e.g., 'A1:D100'). WithCell targets a single cell by address (e.g., 'C5'). WithColumn targets an entire column by letter. WithRowNumber targets an entire row by number. WriteRange writes data to a specified range directly. WithInsertPosition and WithInsertSeparator configure how InsertValue and PrependValue position and separate inserted text within a cell.

Examples

GPAL Fluent: High-level fluent C# API

//Range notation follows standard Excel A1 format. WithRange, WithCell, WithColumn, and WithRowNumber are mutually exclusive - use whichever scope matches your operation.

// SaveTo fills this grid with the range, so it is declared and read afterwards

IGPALGrid<string> summary = GPAL.Grid.ToGPALObject();


// Target a range for reading

GPAL.Excel

.WithFile("data.xlsx")

.WithSheet("Summary")

.WithRange("A2:E100")

.SaveTo(ref summary);


GPAL.PublishSimpleEvent(GPALEventType.NOTICE, $"[{summary.Count()}] rows read");


// Target a single cell for writing

GPAL.Excel

.WithFile("report.xlsx")

.WithSheet("Dashboard")

.WithCell("B5")

.SetValue("Q4 Total");


// Write a range with data

GPAL.Excel

.WithFile("output.xlsx")

.WithSheet("Sheet1")

.WriteRange("A1:C3");

💬 Ask GPAL