Set CodeName on XLSX file in .NET

Hi,


When using Aspose to add a new Sheet to a WorkBook, we need to set the CodeName for this newly added sheet. As the CodeName property on the WorkSheet is readonly, we tried to access the VBAProject of the workbook to set this but we ran into some problems on the road.

When accessing VBAProject property of the WorkBook, all the worksheets CodeName are modified when accessing the property. The sheet name (label) is copied into the CodeName property.

How can we set the CodeName without altering the CodeName of the other sheets ? Why is it Readonly ?

I’ve been able to discover a workaround to set the CodeName using that behavior of the VBAProject property but it’s not clean. If you create a new workbook with Aspose (in-memory), add a new sheet, access the VBAProject property (CodeName is being set) and copy that worksheet to the original workbook, it kind of work.

We are using V16.11 (.NET).

I’ve attached a .NET app to reproduce both behaviors. As you can see if you open the XLSX file in MS-Excel, there are CodeName specified on the second sheet.

Hi,


Thanks for your posting and using Aspose.Cells.

We were able to observe this issue and logged it in our database for a fix.

This issue has been logged as

  • CELLSNET-45179 - Setting CodeName on XLSX file is not working fine

Here is the console output of your sample project when executed with the latest version. I have also attached the screenshot for a reference.

Console Output
Test1 :
Original SheetName and CodeName values :
Worsheet name : Name1 ------ CodeName : Feuil1
Worsheet name : NameWithCodeName ------ CodeName : FakeCodeName

Add new sheet…
ADDED Worsheet name : NewWorkSheetAspose ------ CodeName : Sheet1

Accessing VBAProject properties…

SheetName and CodeName values after accessing VBAProject :
Worsheet name : Name1 ------ CodeName : Name1
Worsheet name : NameWithCodeName ------ CodeName : NameWithCodeName
Worsheet name : NewWorkSheetAspose ------ CodeName : NewWorkSheetAspose
End of test1…


WorkAround :
Original SheetName and CodeName values :
Worsheet name : Name1 ------ CodeName : Feuil1
Worsheet name : NameWithCodeName ------ CodeName : FakeCodeName

Add new sheet with temprorary workbook…
ADDED Worsheet name : NewSheetName ------ CodeName : NewSheetName

SheetName and CodeName values after adding the new sheet :
Worsheet name : Name1 ------ CodeName : Feuil1
Worsheet name : NameWithCodeName ------ CodeName : FakeCodeName
Worsheet name : NewSheetName ------ CodeName : NewSheetName
End of WorkAround…

Hi,


Thanks for using Aspose.Cells.

We have fixed the issue. We did not support parsing VBA project in old version when we add Worksheet.CodeName property, so it was read-only. We will support to set codename of worksheet by Worksheet.CodeName property in the next fix.

Thanks for the quick feedback !


When is your next release ? It will be included in version 17.3.0 ?

Hi,


The next fix (e.g v17.2.5) might be shared in the next few days (2-5 days or so). And, yes, our next official release i.e., Aspose.Cells for .NET v17.3.0 will include this fix, it is scheduled to be released in the second/third week of March, 2017 although the date is not finalized yet.

Thank you.

Hi,


Please try our latest version/fix: Aspose.Cells for .NET v17.2.5 (attached):
Aspose.Cells for .NET v17.2.5 (.NET 2.0)
Aspose.Cells for .NET v17.2.5 (.NET 4.0)
(Note: please choose any of the fixes for your underlying .NET framework version)

Let us know your feedback.

Thank you.

It’s all good, thanks for the quick fix !

Hi,


Thanks for your feedback.

Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you have further queries or issue, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as CELLSNET-45179) have been fixed in Aspose.Cells for .NET 17.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.