Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Sep 25, 2023 8:39 pm

I am building a C# web application using ASP.NET Core (.NET Framework 7.0.103) and FreeSpire.XLS version 12.7.0

In my application, I am creating an export page where users will be able to export various data into an excel spreadsheet. In some cases, I want to make the sheet protected or read only where the user will not be able to make any changes to the downloaded workbook. I understand that I would have to apply the protection to each sheet so currently this is my code:

Spire.Xls.Workbook workbook = new();

// code that builds worksheets goes here

// at the end of the build, make all the sheets protected
foreach(var sheet in workbook.Worksheets)
{
sheet.Protect("test", SheetProtectionType.All);
}


I thought this would work according to the documentation, but I'm not seeing the downloaded workbook being protected. Is this feature exclusive only to the paid version of Spire.Xls? If not, am I doing something wrong here?

jacktorrealba
 
Posts: 3
Joined: Mon Sep 18, 2023 8:25 pm

Tue Sep 26, 2023 2:19 am

Hi,

Thanks for your inquiry.
I have created a simple project, using the free version and your code, but the result document was protected, please refer to the following screenshot.
result.png
result.png (49.2 KiB) Viewed 1132 times


You can create a simple Console App to test this function, if the issue still exists, please share us with your project or Excel Document to help us investigate further. In addition, you can try the latest commercial version.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.XLS

cron