GoogleSheets

Sheet and Spreadsheet Management

CreateSheet adds a new worksheet with the specified name. DeleteSheet removes a worksheet by name or ID. SetSheetName renames a worksheet. SetSpreadsheetTitle changes the name of the entire spreadsheet file. CalculateSum computes the sum of numeric values in a range and returns it as an out string. CalculateCount counts the non-empty cells in a range. WithInsertPosition and WithInsertSeparator configure how InsertAtCell positions content within a cell.

Examples

GPAL Fluent: High-level fluent C# API

//DeleteSheet accepts either a sheet name string or a numeric sheet ID (not the spreadsheet ID). Use ListSheets to get the sheet IDs if working with a dynamically created spreadsheet.

// the Sheets object first, then the credentials that drive the API

GoogleSheets sheets = (GoogleSheets)GPAL.GoogleSheets.ToGPALObject();

sheets.WithCredentials(googleCreds);


// Create a new sheet

sheets.WithSpreadsheet("spreadsheet-id");

sheets.CreateSheet("NewReport");


// Rename a sheet

sheets

.WithSpreadsheet("spreadsheet-id")

.WithSheet("OldName")

.SetSheetName("NewName");


// Calculate sum of a range

string total;

sheets

.WithSpreadsheet("spreadsheet-id")

.WithSheet("Sales")

.WithReadRange("D2:D200")

.CalculateSum(out total);

💬 Ask GPAL