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

Is it an issue in .NET v16.11? so do we need to upgrade the licence to use the latest aspose?

@ksnaspose,

Yes, if it is not working in v16.11 but works in latest version/fix, then surely it was an issue in older version which was fixed in newer versions.

Regarding upgrade your subscription/licensing, please open your license file into notepad (please do not update anything in the license file least it will not work anymore) and check its subscription expiry date. If your subscription expiry date is greater than latest version’s (e.g v18.4.x) release date, then you may use it without any new license or upgrading your existing subscription. If it is less than it, then I am afraid, you have to upgrade your subscription. What is the expiry date of your subscription?

FYI, when you purchase a license for the product, you are authorized to use the license file with any new (and upcoming (official versions)) versions or hot fixes of the component for the next whole year. Moreover, your license will never expire if you continue to use your license with the product’s version/hotfix that should be released before your subscription expiry date.

It looks like your subscription is expired. Also, if you upgrade your subscription now, you can use any new/upcoming versions/fixes of the product for the next whole year for free.

We tried the latest version ASPOSE 18.4 and noticed a strange behavior.
we email excel sheet generated using aspose to our clients.
in our internal testing,
1) when we save the attachment and upload the xls file, it works fine.
2) when we open the xls file from the mail client (outlook 2011) and save, it prompts it is read only and we give a file name and save it to local disk.. When we upload this xls sheet, it complaints the file has corrupted.

So not sure what’s going wrong. Could you please investigate?

To add the one we got from nuget install is Aspose.cells 18.4

@ksnaspose,

We are not sure about your issue. If 1) is fine then 2) should also be fine. I do not think the issue is with Aspose.Cells APIs. Anyways, if you still think it is an issue with Aspose.Cells, kindly do create a sample console application (runnable) using v18.4.x with all the steps involved, zip the project and provide us here (you may exclude Aspose.Cells assembly) to reproduce the issue on our end, we will check it soon.

Hi,

What is the difference between the following APIs

// book.BuiltInDocumentProperties.Comments = “test comments”;
// book.CustomDocumentProperties.Add(“uid”, 100);
// book.Settings.Password = “test”; —> originally used this
book.ProtectSharedWorkbook(“test”); → changed to below

Seems when I use the second api, things working. Also I suspect the built in and custom document properties causing something to break.

seems book.ProtectSharedWorkbook(“test”); is not setting the password at all.

I am lost. could you please help. Thanks.

Related to this >> Issue reported earlier

@ksnaspose

Thanks for using Aspose APIs.


BuiltInDocumentProperties

These are predefined properties provided by Microsoft Excel. Key Name exists already but Key Value is provided by you.

CustomDocumentProperties

These are not predefined and you add them. You provide both Key Name and Key Value by yourself.

Please see these articles for more detail about both of them.


Workbook.Settings.Password

This is use to protect your Excel file with password. In the following document, Excel file is password protected and it also explains how to specify encryption for protection.


ProtectSharedWorkbook

This is not for normal Excel files but for those Excel files which are shared on network with multiple users. Please see this document for more help.

We investigated further and the same code works ( ability to open the excel file with password) in

Windows 7 professional standard but not in Windows Server 2008 R2 Standard (service pack 1).
Is there any dependency on OS, culture info etc., ? Thanks.

@ksnaspose

Thanks for using Aspose APIs.

Please try the following code with the most recent version and let us know your feedback. Please also try the code with Book1.xls provided by us.

Download Link:
Input-Book1.zip (16.1 KB)

C#

String ver = CellsHelper.GetVersion();

Console.WriteLine("Aspose.Cells Version: " + ver);

string fileName = "test.xls";

FileFormatInfo finf = FileFormatUtil.DetectFileFormat(fileName);

LoadOptions opts = new LoadOptions(finf.LoadFormat);
opts.Password = "test";

byte[] bts = File.ReadAllBytes(fileName);
MemoryStream ms = new MemoryStream(bts);

Workbook wb = new Workbook(ms, opts);
wb.Save("output.pdf");

Hi,
Sorry as requested, will you be able to provide a .NET 3.5 version of Aspose 18.4.3

@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 ((Dropbox - ExcelFile - Simplify your life)), 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: