Last active
May 22, 2024 13:06
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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