Last active
May 22, 2024 13:08
-
-
Save openize-cells-gists/f5e912c03b170cd571e1a118d5dde943 to your computer and use it in GitHub Desktop.
This C# example showcases how to programmatically insert rows into an Excel worksheet at a specified row index 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]; | |
// Define the starting row index and the number of rows to insert | |
uint startRowIndex = 5; | |
uint numberOfRows = 3; | |
// Insert the rows into the worksheet | |
firstSheet.InsertRows(startRowIndex, numberOfRows); | |
// Get the total row count after insertion | |
int rowsCount = firstSheet.GetRowCount(); | |
// Output the updated row count to the console | |
Console.WriteLine("Rows Count=" + rowsCount); | |
// Save the workbook to reflect the changes made | |
wb.Save(filePath); | |
Console.WriteLine("Rows inserted and workbook saved successfully."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment