Aspose throwing error "Invalid Excel2007Xlsx file format "

Iam trying to open the attached xlsm file using Aspose.Cells.Workbook Open method. Its failing with the error “Invalid Excel2007Xlsx file format”. I can open the same file in excel without any issue.


The attached file was created from xlsx file using the below code

using (excelSheet = SpreadsheetDocument.Open(stream, true))
{
excelSheet.ChangeDocumentType(DocumentFormat.OpenXml.SpreadsheetDocumentType.MacroEnabledWorkbook);
const string VbaProjectRelationShipType = “http://schemas.microsoft.com/office/2006/relationships/vbaProject”;
VbaProjectPart vbaProjectPart = null;
using (MemoryStream memoryStream = new MemoryStream(documentWithMacroContent, false))
{
using (SpreadsheetDocument documentWithMacro = SpreadsheetDocument.Open(memoryStream, false))
{
WorkbookPart mainPartOfDocumentWithMacro = documentWithMacro.WorkbookPart;
foreach (IdPartPair partPair in mainPartOfDocumentWithMacro.Parts)
{
if (partPair.OpenXmlPart.RelationshipType == VbaProjectRelationShipType)
{
vbaProjectPart = (VbaProjectPart)partPair.OpenXmlPart;
break;
}
}

WorkbookPart mainPartOfWorkbook = spreadSheetContent.WorkbookPart;

if (mainPartOfWorkbook.GetPartsCountOfType() > 0)
{
mainPartOfWorkbook.DeleteParts(mainPartOfWorkbook.GetPartsOfType());
}

if (vbaProjectPart != null)
{
mainPartOfWorkbook.AddPart(vbaProjectPart);
}
}
}
}

Hi,


Thanks for providing us the template file.

I have found the issue as you have mentioned. I have logged a ticket for the issue with an id: CELLSNET-30989. We will look into the issue soon.

Thank you.

Hi,

We have fixed this issue. Please download: Aspose.Cells for .NET v7.0.1.6

The issues you have found earlier (filed as 30989) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.