File Encryption in Unix

Hi,

I have been trying to encrypt a .xls file from Unix platform with following code.

Workbook workbook = new Workbook();
System.out.println("fielName: "+fileName);
workbook.open(fileName, FileFormatType.CSV);
System.out.println("3");
workbook.protectFile(ProtectionType.OPEN_FILE,"pass");
System.out.println("4");
workbook.setEncryptionOption(EncryptionType.XOR, 40);
//workbook.setEncryptionOption(EncryptionType.STONG_CRYPTOGRAPHIC_PROVIDER, 128);
System.out.println("5");
workbook.save(fileName, FileFormatType.CSV);

The code executes without any exceptions. But the file is not password protected. Please advice on this.

Regards,

Rohan

Hi,


How could you encrypt/password protect a CSV file in MS Excel? I think you cannot encrypt / password protect a CSV file. You may encrypt/password protect a file in XLS, XLSX etc. formats.

For confirmation, you may try to check (by manually) in MS Excel. If you have different opinion, give us your sample file (encrypted csv file) here, we will check it soon.

Thank you.

Hi,

Actually the file on Unix server is .xls. I first tried without sepcifying any FileFormatType. Below is the code:

Workbook workbook = new Workbook();
workbook.open(fileName);
workbook.protectFile(ProtectionType.OPEN_FILE,"pass");
workbook.setEncryptionOption(EncryptionType.XOR, 40);
//workbook.setEncryptionOption (EncryptionType.STONG_CRYPTOGRAPHIC_PROVIDER, 128);
workbook.save(fileName);

But this gives me following error.

java.lang.IllegalStateException: This is not a structured storage file.
at com.aspose.cells.cC.(Unknown Source)
at com.aspose.cells.gg.a(Unknown Source)
at com.aspose.cells.gg.a(Unknown Source)
at com.aspose.cells.gg.(Unknown Source)
at com.aspose.cells.iG.b(Unknown Source)
at com.aspose.cells.iG.a(Unknown Source)
at com.aspose.cells.iG.a(Unknown Source)
at com.aspose.cells.Workbook.open(Unknown Source)

Please note that i am running this on Unix server. so please let me know if it requires any extra setting or some extra code. Thanks for the response.

Regards,

Rohan.

Hi,


This is not a structured storage file.” Well, this error might occur if your underlying/so called xls file is not native Excel file. Could you check it or attach it here, we will check the issue soon.

Thank you.

Hi. I checked the file. And also tested the code for two different files with two different types:

1. Microsoft Office Excel Worksheet.

2. Microsoft Office Excel 97-2003 Worksheet.

The first type executes perfectly. But with the second type i get the "This is not a structured storage file" exception. Please look into it. Thanks.

Regards,

Rohan.

Hi,


Please give/attach your file for which you get This is not a structured storage file exception, we will check your issue soon.

Thank you.