Excel

Writing Cell Values

SetValue replaces the entire content of the targeted cell with the provided string. ReplaceWith replaces content that matches a search value (configure with WithSearchValue). InsertValue inserts text at a specific position within the cell (configure position with WithInsertPosition). PrependValue adds text before the current cell content. AppendValue adds text after the current cell content. ClearRanges clears the content of all previously specified ranges.

Examples

GPAL Fluent: High-level fluent C# API

//WithSearchValue must be set before ReplaceWith when doing a search-and-replace. ClearRanges acts on all ranges previously targeted within the chain.

// Replace all cells in a column that match a value

GPAL.Excel

.WithFile("data.xlsx")

.WithSheet("Contacts")

.WithColumn("C")

.WithSearchValue("N/A")

.ReplaceWith("Unknown");


// Append a suffix to a cell value

GPAL.Excel

.WithFile("report.xlsx")

.WithSheet("Sheet1")

.WithCell("A1")

.AppendValue(" (verified)");


// Insert text at position 5 in a cell

GPAL.Excel

.WithFile("data.xlsx")

.WithSheet("Sheet1")

.WithCell("B2")

.WithInsertPosition(5)

.InsertValue("[NOTE] ");

💬 Ask GPAL