Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This article compares hiding and unhiding worksheets with VSTO, using either C# or Visual Basic, with performing the same task with Aspose.Cells, again using either C# or Visual Basic. Aspose.Cells lets you work without Microsoft Excel installed.
The steps to hide a worksheet are:
To unhide a worksheet again, simply toggle visibility on for the hidden sheet.
The code samples below first show how to hide a worksheet. The first samples show the process with VSTO, using either C#, compared to using Aspose.Cells, again using either C#.
The second set of code samples shows the line used to unhide the worksheet in VSTO or Aspose.Cells.
Below are code samples for VSTO and Aspose.Cells that illustrate how to hide a worksheet in a workbook.
//Instantiate the Application object.
Excel.Application excelApp = Application;
//Specify the template Excel file path.
string myPath = "Book1.xls";
//Open the Excel file.
excelApp.Workbooks.Open(myPath, Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
//Get the first sheet.
Excel.Worksheet objSheet = (Excel.Worksheet)excelApp.ActiveWorkbook.Sheets["Sheet1"];
//Hide the worksheet.
objSheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;
//Save As the Excel file.
excelApp.ActiveWorkbook.Save();
//Quit the Application.
excelApp.Quit();
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Specify the template Excel file path.
string myPath = "Book1.xls";
//Open the Excel file.
workbook.Open(myPath);
//Get the first sheet.
Aspose.Cells.Worksheet objSheet = workbook.Worksheets["Sheet1"];
//Hide the worksheet.
objSheet.IsVisible = false;
//Save As the Excel file.
workbook.Save("Book1.xls");
Below are code samples for VSTO and Aspose.Cells that illustrate how to unhide a worksheet in a workbook.
//Unhide the worksheet.
objSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
//Unhide the worksheet.
objSheet.IsVisible = true;
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.