Some built-in properties are lost during XLS-XLSM-XLS conversion of encrypted workbook

Hi, Aspose team.

Issue (actual behavior): Aspose.Cells 24.7. Some built-in properties are lost during XLS-XLSM-XLS conversion of encrypted workbook. See screenshot.

Other details: XLS is encrypted. Maybe related to Empty strings in some buil-in properties of encrypted OOXML workbook.

issue2.zip (721.2 KB)

var filePath = "sample.xls";
var resultFilePath = filePath + ".xlsm";

using (var wb = new Workbook(filePath, new LoadOptions(LoadFormat.Excel97To2003)
       { Password = "test", }))
{
    wb.Settings.Password = null;
    wb.Save(resultFilePath, SaveFormat.Xlsm);
}
using (var wb = new Workbook(resultFilePath, new LoadOptions()))
{
    wb.Settings.Password = "1";
    wb.Save(resultFilePath + ".xls", SaveFormat.Excel97To2003);
}

For internal reference: MDP-18515.

Thanks.

@oleksii88
By testing with sample file and code on the latest version v24.7, we can reproduce the issue. Found that some built-in properties are lost during XLS-XLSM-XLS conversion of encrypted workbook.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-56344

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@oleksii88
We have resolved this issue and fix will be included into next release 24.8.
CELLSNET56343.zip (9.2 KB)

Please set XlsSaveOptions.EncryptDocumentProperties property as true, then we will ignore encrypting properties.

 XlsSaveOptions saveOptions = new XlsSaveOptions();
 saveOptions.EncryptDocumentProperties = false;
 workbook.Save(Constants.destPath + "CellsNet56344.xls", saveOptions);

In older Excel version, properties must be encrypted if the file is encrypted, otherwise the file is corrupted for MS Excel. But it seems that Office365 has changed its behavior.

Hi, @simon.zhao and @John.He

May I get a pre-release version of Aspose.Cells 24.8 for internal testing?

Thanks.

@simon.zhao, @John.He

You said that the issue is related to document properties encryption. But not all properties disappeared (were not shown in the dialog, see screenshot attached to the first post). If all properties are encrypted I would expect all of them to be missing in the dialog.

Also, there was mentioned that Office365 has changed behavior. However, properties are also missing when file is opened in Office Pro 2019.

Can you please give more details (explain this behavior)?

Thanks.

@oleksii88
Sorry, we are unable to provide you with a fixed version. According to company regulations, only those with priority services will be provided with fix versions, so if you want to obtain fix versions faster, you need to purchase priority support. If there is no priority service, fix will also be released in the next release version.
You may check our paid support option where issues are prioritized and posses highest priority if your issue is a real blocker.

In addition, please refer to the attachment for the latest generated result file. CellsNet56344.zip (633.3 KB)

@oleksii88

Please decrypt the xlsx file with MS Excel, and unzip the decrypted xlsx file, you will find there are 3 xml file in docprops directory. Though Excel contains 3 kinds of document properties: app, core and custom, we split document properties to built-in (app and core) and custom. In encrypted xls file, only all properties of core.xml are encrypted in the previous Excel version.

The issues you have found earlier (filed as CELLSNET-56344) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

hi @simon.zhao

There was a question about the encryption of built-in properties that I might not have noticed.

You said:

In older Excel version, properties must be encrypted if the file is encrypted, otherwise the file is corrupted for MS Excel. But it seems that Office365 has changed its behavior.

However, the reported issue can be reproduced in MS Office 2013, 2016, 2019.

Do you have any idea why?


Aspose.Cells 24.8 provides the EncryptDocumentProperties property to control behavior on save. However, it does not sound good to set EncryptDocumentProperties to false by default.

Is there a way to identify that the opened workbook has properties encrypted?

This would allow setting EncryptDocumentProperties only when it is needed.

var wb = new Workbook("wb.xls");
var propsEncrypted = wb.????;
// convert to xlsm
// read generated xlsm
// convert back to XLS


xlsmWb.Save("new.xls", new XlsSaveOptions 
{
   EncryptDocumentProperties = propsEncrypted,
});

Thanks.

@simon.zhao

Also, the following code does not produce the issue (Microsoft 365 Excel shows all built-in properties) even though EncryptDocumentProperties is not set to false:

var wb = new Workbook()
{
    BuiltInDocumentProperties =
    {
        Author = "author",
        Title = "title",
        Comments = "comments",
        Keywords = "keywords",
        LastSavedBy = "lastSavedBy",
        Manager = "manager",
        Company = "company",
        Category = "category",
        Subject = "subject",
        ContentStatus = "contentStatus",
        HyperlinkBase = "hyperlinkBase",
        Template = "template",
    }
};

wb.Settings.Password = "1";
wb.Save(@"no-issue.xls", new XlsSaveOptions() 
  { EncryptDocumentProperties = true });

Thanks.

@oleksii88,

We require thorough evaluation of your requirements and we will evaluate on if the workbook has properties encrypted or not. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-56459

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

We will evaluate/check your findings and then provide details on it.

@simon.zhao

Additional information.

I also noticed that the XLS file generated by the code from the initial post in this thread does not have the \005SummaryInformation stream.

The file structure is:

  • _CompObj
  • Workbook
  • encryption
  • User Names
  • MsoDataStore
    • 1
      • item
      • Properties
  • Revision Log
  • _DocumentSummaryInformation

Whereas, the structure of the XLS file generated by this code:

  • Workbook
  • _SummaryInformation
  • _DocumentSummaryInformation

It sounds that there is some issue in Aspose.Cells when it fails to create \005SummaryInformation stream with built-in properties (see code in the initial post in this thread).

@oleksii88,

Thanks for the additional information.
Let us evaluate your findings and then we will get back to you.

@oleksii88
Some additional data( Such as OleObject, XmlMap, control X…) must be embedded into “encryption” stream when the file is encrypted. If “encryption” stream exists, \005SummaryInformation steam must be embedded into “encryption” stream too, otherwise “corrupted file” message box will pop up in some old Excel version.

Because there is no data which should be encrypted into “encryption” stream, so \005SummaryInformation stream is not encrypted too.

@oleksii88
It should be that Office365 has made some adjustments recently.
1). When encrypting xls files, \ 005SummaryInformation stream should not be encrypted.
2). If xlsx file is encrypted , all Document Properties are still saved to \005SummaryInformation and * _DocumentSummaryInformation stream in your template file.
But even if I upgrade to the latest Office 365, I still can’t get the same files as you provided :sweat_smile: . I can not view document properties in win after encrypting the xlsx in Office 365.

So now please SaveOptions.EncryptDocumentProperties as false, it will work same as your Office 365.