Skip to content

Instantly share code, notes, and snippets.

@openize-cells-gists
Last active May 22, 2024 13:06
Show Gist options
  • Save openize-cells-gists/f8ba9d163eeee8a694c612ea53193fea to your computer and use it in GitHub Desktop.
Save openize-cells-gists/f8ba9d163eeee8a694c612ea53193fea to your computer and use it in GitHub Desktop.
This C# example demonstrates how to select a specific range within an Excel worksheet and set the same value to all cells within that range using the Openize.Cells Sdk.
using Openize.Cells;
// Load the workbook from the specified file path
using (Workbook wb = new Workbook(filePath))
{
// Access the first worksheet in the workbook
Worksheet firstSheet = wb.Worksheets[0];
// Select a range within the worksheet
var range = firstSheet.GetRange("A1", "B10");
Console.WriteLine($"Column count: {range.ColumnCount}");
Console.WriteLine($"Row count: {range.RowCount}");
// Set a similar value to all cells in the selected range
range.SetValue("Hello");
// Save the changes back to the workbook
wb.Save(filePath);
Console.WriteLine("Value set to range and workbook saved successfully.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment