Created
May 22, 2024 12:54
-
-
Save openize-cells-gists/fbbb3bf00e274468fbfe14ec8762e549 to your computer and use it in GitHub Desktop.
Remove Worksheet from a Workbook in C#
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; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string filePath = "Z:\\Downloads\\test_spreadsheet.xlsx"; // Replace with the path to your file | |
using (var workbook = new Workbook(filePath)) | |
{ | |
// Assuming the worksheet to remove is named "SheetToRemove". | |
bool removed = workbook.RemoveSheet("SheetToRemove"); | |
if (removed) | |
{ | |
// Save the changes to the workbook. | |
workbook.Save(); | |
Console.WriteLine("Worksheet removed and changes saved successfully!"); | |
} | |
else | |
{ | |
Console.WriteLine("The specified worksheet was not found."); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment