Set password protection for excel files in .NET

Hi
Its very urgent need , we are working on excel for read/write protection using vb.net program
,The password protection is working on local machine, we are deployed oin server, the password protection not working …
How to resolve tell me

@harieswer,

Thanks for providing us some details.

Please make sure you are using our latest version/fix: Aspose.Cells for .NET v18.5.1 on your server:

If you still find the issue with v18.5.1, we need your sample code (runnable) with template file or preferably a sample console application (you may zip the project prior attaching it here) to reproduce the issue on our end, we will check it soon.

Hi
right now we deploy the latest version of Aspose.cell 18.5.1 dill file into server, but the problem not resolved,

seeting password protection is working in local machine, once we deployed in server, its not working

iam sending Sample code ;;;

Public Function SetPasswordToExcelFile(FileName As String, Password As String) As Boolean
Dim fstream As FileStream = New FileStream(FileName, FileMode.Open)
'Instantiating a Workbook object and Opening the Excel file through the file stream
Dim excel As Workbook = New Workbook(fstream)
excel.Settings.WriteProtection.Password = Password
fstream.Close()
excel.Save(FileName, SaveFormat.Excel97To2003)
return true
End Function

– the bove code is working well in local machine using suported Aspose.Cells dill, but we deployed dlls, in live server , the code is running , we are not getting any exception, the excel file also comming, but the excel file does not have read /write permssions…

Please help how to resolve this problem … what i have to do need to work in server ?

@harieswer,

Please note, Aspose.Cells only needs .NET framework version to be installed on the system (OS), it works seamlessly on any OS (whether a client or server), see the System Requirements page for your reference:

I have tested your scenario/case a bit using your sample code with a simple template file, it works fine and the output has been set for write encryption password. So, when I opened the output file into MS Excel manually, it prompts me for a password.

Your problem can be template file specific, so could you provide your template file and output Excel file, we will check it soon.

PS. please note, there is nothing (options) to be set on the server to work with Aspose.Cells APIs. Please check the first few lines above in this reply.

Hi

iam saying one thing My server does not have visual studio,… …In the server we will do deploy the applications only…

So we need visual studio in server to run this Aspose.cell dill ? --> tell me briefly …6400.zip (2.0 KB)
pasword: pass6400
this exce l file password protectoin working in local machine, but not server

Hi
The Server configuration

Windows server 2012 standard 64 bit
no visual studio

@harieswer

Thanks for using Aspose APIs.

Please read this post i.e #35 in this topic. It should help you fix your issue. Let us know your feedback.

H shakeel.faiz

i think you dont understand my problem …
my intention is setting Protected password to existing excel file, …using below code

Public Function SetPasswordToExcelFile(FileName As String, Password As String) As Boolean
Dim fstream As FileStream = New FileStream(FileName, FileMode.Open)
'Instantiating a Workbook object and Opening the Excel file through the file stream
Dim excel As Workbook = New Workbook(fstream)
excel.Settings.WriteProtection.Password = Password
fstream.Close()
excel.Save(FileName, SaveFormat.Excel97To2003)
return true
End Function

Iam setting password to the existing excel fille while perform read /write opertions on excel file …
The dill is working well in local machine… we deployed dlls and files in server … the excel file and password passing an input perameters to method SetPasswordToExcelFile, the method excuting successfully ,iam not getiing any exception , but the Excel file does not have protected password, if we select the file its opening directly without asking password…

Please help we what i have to do … i need very urgent we are using Licensed Aspose librariess. only…

.

@harieswer

If I am not mistaken, this is the correct way of Setting Password of Excel file.

VB_NET

Dim excel As Workbook = New Workbook("yourExcel.xls")

'This is the correct way to set password of the Excel file
excel.Settings.Password = "pass6400"

excel.Save("output.xls")

Now, if you will try to open output.xls via Aspose.Cells or MS-Excel, it will ask you to provide password.

the Code is correct fine and its working in local computers …
, but the code exccuting in server , no exceptions no errors … ,
, but the excel file does not have password, its opening directly without asking password … ,

Please give me quick reply …

@harieswer

Please reply

If you generate output.xls on Local Machine, does it open in Server Machine in Microsoft Excel?

If you generate output.xls on Server Machine, does it open in Local Machine in Microsoft Excel?

I still think, your code is wrong you should try the code I sent you.

Thank u ,…

Thank u very much the code is running Perfectly…

@harieswer

Thank you and have a good day.