Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save openize-cells-gists/fbbb3bf00e274468fbfe14ec8762e549 to your computer and use it in GitHub Desktop.
Save openize-cells-gists/fbbb3bf00e274468fbfe14ec8762e549 to your computer and use it in GitHub Desktop.
Remove Worksheet from a Workbook in C#
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