Excel

Opening and Navigating Excel Files

WithFile sets the Excel file to work with using a GPALFile reference. WithSheet selects the target worksheet by name (string) or by index (integer). Close closes the workbook - pass true to save changes before closing. ToGPALObject returns the IGPALExcel interface for storage or injection. All subsequent operations (read, write, compare) apply to the sheet selected with WithSheet.

Examples

GPAL Fluent: High-level fluent C# API

//WithSheet can take a sheet name string or a zero-based integer index. If you do not call WithSheet, GPAL operates on the first sheet by default.

// Open a workbook and select a sheet by name

GPAL.Excel

.WithFile("report.xlsx")

.WithSheet("Sales Data")

.WithRange("A1:D50")

.SaveTo("extracted.csv");


// Open, modify, and close with save

GPAL.Excel

.WithFile("data.xlsx")

.WithSheet(0) // first sheet by index

.WithCell("B2")

.SetValue("Updated")

.Close(true);

💬 Ask GPAL