Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
This article explains how you can easily disable the Excel-protected view message using the advanced C# Excel library, IronXL.
IronXL is a powerful C# library that provides developers with an efficient and straightforward way to work with Excel files within their applications. Whether you need to read, write, or manipulate Excel data, IronXL simplifies the process and empowers you to accomplish complex tasks with ease. With its intuitive API and extensive functionality, IronXL eliminates the need for manual Excel file handling, saving you valuable time and effort. This guide will explore the key features and capabilities of IronXL, demonstrating how it can be utilized to streamline Excel-related operations and enhance your C# applications. Whether you are building a data analysis tool, generating reports, or performing data migrations, IronXL is a valuable asset that unlocks the full potential of Excel integration in your C# projects.
Before you can start working with IronXL and disable protected view in Excel files using the C# programming language, there are a few prerequisites that need to be in place. These prerequisites include:
By ensuring that these prerequisites are met, you'll be ready to dive into the process of working with IronXL.
To begin working with IronXL, the first step is to create a new project in Visual Studio.
Open Visual Studio, go to File and click on the New Project button.
New Project in Visual Studio
A new window will appear. In this window, select "Console Application" and click on the Next button.
Create a new Console Application
Your new project in Visual Studio is created.
IronXL offers several ways to install this library, with the following being the most effective approaches:
Use the NuGet Package Manager to add the IronXL library to your Visual Studio project. Search for IronXL in the Browse tab:
Simply choose the package and begin the installation procedure after finding IronXL in the search results. After the installation is complete, you may begin using the IronXL library in your project.
The following screenshot shows how to use Visual Studio to access the NuGet Package Manager.
Navigate to NuGet Package Manager
IronXL in search results:
Search and install the IronXL package in NuGet Package Manager UI
The command-line interface is a common approach for package installation among developers. Follow these instructions to install IronXL from the command line:
In the console, type the following command:
Install-Package IronXL
Install-Package IronXL
When the procedure is finished, you may begin using the IronXL library in your project.
Install IronXL in the Package Manager Console
IronXL is a top-of-the-line Excel Library, using its advanced features you can easily disable protected view messages using C# code. First, we need an example Excel file that has protected view enabled.
An Excel file with the protection view enabled
You can easily disable the protected view message with the following code example:
using IronXL;
class Program
{
static void Main(string[] args)
{
// Load the Excel workbook with protection view enabled.
WorkBook workBook = WorkBook.Load("sample1.xlsx");
// Get the default worksheet from the workbook.
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Disable the protection on the worksheet.
workSheet.UnprotectSheet();
// Save the modified workbook to a new file.
workBook.SaveAs("sample2.xlsx");
}
}
using IronXL;
class Program
{
static void Main(string[] args)
{
// Load the Excel workbook with protection view enabled.
WorkBook workBook = WorkBook.Load("sample1.xlsx");
// Get the default worksheet from the workbook.
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Disable the protection on the worksheet.
workSheet.UnprotectSheet();
// Save the modified workbook to a new file.
workBook.SaveAs("sample2.xlsx");
}
}
Imports IronXL
Friend Class Program
Shared Sub Main(ByVal args() As String)
' Load the Excel workbook with protection view enabled.
Dim workBook As WorkBook = WorkBook.Load("sample1.xlsx")
' Get the default worksheet from the workbook.
Dim workSheet As WorkSheet = workBook.DefaultWorkSheet
' Disable the protection on the worksheet.
workSheet.UnprotectSheet()
' Save the modified workbook to a new file.
workBook.SaveAs("sample2.xlsx")
End Sub
End Class
In this code, we open an Excel workbook using the WorkBook.Load
method and then load the default Excel worksheet using the workBook.DefaultWorkSheet
property. Next, workSheet.UnprotectSheet
disables the Protected View as required, and finally, workBook.SaveAs
is used to save the modifications to a new Excel file.
Here is the output screenshot.
The output Excel file
As you can see, Microsoft Excel's enable editing functions are now available.
IronXL is a powerful C# library that simplifies working with Microsoft Office Excel files in your applications. By following the steps outlined in this guide, you can easily disable the Protected View feature in Excel using C#.
IronXL's intuitive API and extensive functionality make it a valuable tool for manipulating Excel files, saving you time and effort in your development process. By installing the IronXL library, creating a new project in Visual Studio, and utilizing the provided code examples, you can effectively disable Protected View and unlock the full potential of Excel integration in your C# projects.
Furthermore, IronXL offers a wide range of features to interact with Excel WorkBooks, WorkSheets, and Cells level such as converting between popular formats, cell data formatting, merging cells, inserting math functions, and even managing charts and adding images.
For more information on how protected view messages work, visit this blog. Please visit other tutorials and code examples to read Excel files.
IronXL is available to users for a free trial and can be licensed for commercial use with its Lite package starting from $749 only.
IronXL is a powerful C# library that provides developers with an efficient and straightforward way to work with Excel files within their applications. It simplifies the process of reading, writing, and manipulating Excel data.
Before using IronXL, ensure you have a suitable development environment such as Visual Studio, a basic understanding of C#, and the IronXL library installed in your project.
To create a new C# project in Visual Studio, open Visual Studio, go to 'File', click 'New Project', select 'Console Application', choose the target framework, set the location and name, and click 'Create'.
In Visual Studio, use the NuGet Package Manager to search for IronXL in the 'Browse' tab, select the package, and follow the installation procedure.
Navigate to 'Tools' > 'NuGet Package Manager' > 'Package Manager Console' in Visual Studio. In the console, type 'Install-Package IronXL' and press Enter to install the package.
You can disable Protected View in Excel files using IronXL by loading the Excel workbook, accessing the default worksheet, using 'workSheet.UnprotectSheet()' to disable protection, and then saving the modified workbook.
IronXL offers features like converting between spreadsheet formats, cell data formatting, merging cells, inserting math functions, and managing charts and images in Excel files.
Yes, IronXL is available for a free trial, and it can be licensed for commercial use with its Lite package starting from a specific price.