Issue with embedding password protected excel in another excel using Aspose.cell

Hi Team,

We are facing an issue while embedding a password protected excel in another excel using aspose.cell. Below is the sample of code we are using. We are able to see the worksheet icon embedded in the excel. But when we click the icon, we are getting the error message as “Cannot start the source application for the object”

        FileStream fWrite = File.OpenRead(excelPath);
        byte[] objectData = new byte[fWrite.Length];
        fWrite.Read(objectData, 0, objectData.Length);
        fWrite.Close();
       
        byte[] binaryImg = File.ReadAllBytes(imgFile);            
        Workbook workbook = new Workbook();
        Worksheet worksheet = workbook.Worksheets[0];
        worksheet.OleObjects.Add(14, 3, 40, 80, binaryImg);
        worksheet.OleObjects[0].ObjectData = objectData;
        worksheet.OleObjects[0].Text = "test";
        worksheet.OleObjects[0].DisplayAsIcon = true;
        worksheet.OleObjects[0].HeightInch = 0.64;
        worksheet.OleObjects[0].WidthInch = 0.78;                   
        worksheet.OleObjects[0].ObjectSourceFullName = (excelPath);
        worksheet.OleObjects[0].FileFormatType = FileFormatType.Unknown;
        workbook.Save(outPutPath, Aspose.Cells.SaveFormat.Xlsx);

We tried making the FileFormatType as Xlsx. During that time we are getting the error message as “Excel found unreadable content”.
Can you please provide a solution for this approach?

Thanks,
Mahith Mohan

@Mahith_Mohan,
We have logged the issue as “CELLSNET-49087” in our database for investigations. Once we will have some news for you, we will update you in this topic.

@Mahith_Mohan,
If you embed a password protected into the file in MS Excel, password must be provided and a decrypted file is embedded.
So please decrypt the file before embedding as the following codes:

LoadOptions options = new LoadOptions();
options.Password = "1234";
Workbook workbook = new Workbook(dir + "book1.xlsx",options);
workbook.Settings.Password = null;
MemoryStream ms = new MemoryStream();
workbook.Save(ms, SaveFormat.Xlsx);

Or please check whether the file is encrypted.

FileFormatInfo info = FileFormatUtil.DetectFileFormat(excelFileNameAndPath);
Assert.AreEqual(info.IsEncrypted,true);