We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Loading a password protected encrypted file via Aspose.Cells in .NET

@ksnaspose

You may try it with the following .NET 2.0 version.

Hi,
It works with your input file in both windows 7 and windows server 2008.
But our internal file able to upload in windows 7, but fails in windows server 2008.
and we get the following error

Unhandled Exception: Aspose.Cells.CellsException: Invalid password.
at :spades:?? .:slight_smile: (♫ ? :slight_smile:)
at :spades:?? .:slight_smile:(MemoryStream :slight_smile:)
at :spades:?? .:heart:(☼ :slight_smile:)
at :spades:?? .:clubs:(☼ :slight_smile:)
at Aspose.Cells.Workbook.:slight_smile:(Stream :slight_smile:, LoadOptions :heart:, Boolean :clubs:)
at Aspose.Cells.Workbook…ctor(Stream stream, LoadOptions loadOptions)
at AsposeTest.Program.ReadAndSave(String src, String dest, String pwd) in C:\AsposeTest\Program.cs:line 33
at AsposeTest.Program.Main(String[] args) in C:\AsposeTest\Program.cs:line 19

Do you want the project and the samlpe excel file?

Hi,
I have uploaded the excel files one able to upload and other fail to upload

File Names:

Open-outline-save.xls >> This is the email attachment, we right click in outllook . save and try to open using aspose. It works both in windows 7 and windows server 2008.

Error-Open-inline-save.xls >> This is the email attachment, we open from the mail, enter password, make our changes, save. we try to open using aspose and It works in windows 7, but fails in windows server 2008

@ksnaspose

Thanks for using Aspose APIs.

Please share the passwords of both XLS files. i.e.

  • Error-Open-inline-save.xls
  • Open-outline-save.xls

Please share the console application project. Please also share the screenshots of Windows Server 2008 errors or any other helpful screenshots as well.

Ok added the project to the same share. Will also add the screen shot of windows server errorerrr-msg-aspose.png (7.2 KB)

I have also uploaded my project in the same link here

@ksnaspose

Thanks for using Aspose APIs.

Your code is working fine at my end. Please also set the memory position to zero like this.

MemoryStream ms = new MemoryStream(bts);
ms.Position = 0; //<<<<<<<<Try this line
Console.WriteLine("Writing file " + dest);
Workbook wb = new Workbook(ms, opts);

Please also let us know the Language and Regional Settings (as shown below) from Control Panel (Please share its screenshot) of your Windows Server OS. Also let us know if you are using 32-bit or 64-bit platform.

region-date-settings.png (8.5 KB)

We’re using 64 bit operating Windows 2008 server (vmware).
The platform target used for the project : Any CPU

Tried the following and still failed

ms.Position = 0; //<<<<<<<<Try this line

D:\asptest>AsposeTest.exe
Aspose.Cells Version: 18.4.3
Reading file open-outline-save.xls
Writing file open-outline-save2.xls
Reading file Error-Open-inline-save.xls
Writing file Error-Open-inline-save2.xls

Unhandled Exception: Aspose.Cells.CellsException: Invalid password.

@ksnaspose

Thanks for your further information. We will prepare the environment of Windows 2008 Server. Please also let us know the complete steps to test this issue.

e.g.

1 - Install Windows Server 2008
2 - Install Service Pack
3 - Install Microsoft .NET Framework 2.0
4 - Install Visual Studio 2015 etc.


I have also installed the Windows Server 2008 R2 Standard on my machine. Please see the screenshot given below for a reference.

Updated the steps

1 - Install Windows Server 2008 Release 2
2 - Install Service Pack
3 - Install Microsoft .NET Framework 3.5
4 - Install Visual Studio 2010

download the project provided earlier ((https://www.dropbox.com/sh/mm1lcsd3l4pgz5r/AAAK-RcRQf4yx5R73ehBUSVxa?dl=0)), compile and run.

@ksnaspose

We are afraid, we could not replicate the exception as shown in the following screenshot. However, we have logged this issue (i.e. CELLSNET-46105) in our database for further investigation and evaluation. We will look into it more and fix the issue if possible. Once, we will have some news for you, we will let you know asap.

Screenshot:

Is it possible to add a bit of verbose information to the exception and provide a patch dll. I can use it to re-run in my end and pass the exception information to you. Let me know, if it works.

@ksnaspose

Thanks for using Aspose APIs.

Please download and try the following fix for your issue CELLSNET-46105 and let us know your feedback.

Sorry, it didn’t work. Attached the image.

image.png (5.4 KB)

@ksnaspose

Thanks for using Aspose APIs.

Please try the following simplest of the code. Please note, we could not replicate this issue on our development machines as well, so we do not know how to fix it. Do you have any suggestions how should we fix it?

C#

LoadOptions opts = new LoadOptions(LoadFormat.Excel97To2003);
opts.Password = "test123";

Workbook wb = new Workbook("Error-Open-inline-save.xls", opts);

@ksnaspose

The two files use different Encryption Algorithm.

The Encryption Algorithm of the Error-Open-inline-save.xls file is MD5.

Please simply execute the following code without any other code:

System.Security.Cryptography.MD5CryptoServiceProvider m_MD5 = new MD5CryptoServiceProvider(); 

If you get exception, please update Enabled of

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy 

as 0 in the Registry Editor.


Screenshot:

Thanks Shakeel. That worked like a charm. Thanks for you and your teams support!

@ksnaspose,

Good to know that your issue is sorted out by following the workaround. Feel free to write us back if you have further comments or questions, we will be happy to assist you soon.