Protect VBA Project of Excel Workbook and Lock it for Viewing, Specify Sort Warning While Sorting Data and Apply DBNum Custom Pattern Formatting in .NET

Share on FacebookTweet about this on TwitterShare on LinkedIn

Aspose.Cells for .NET logoWe are pleased to announce our next version of Aspose.Cells for .NET v17.4.0. The new release includes some valuable features and other enhancements with critical bug fixes. We have added certain features regarding VBA project’s protection for the users. There is also an enhancement for data sorting and custom pattern formatting. Our clients may get the powerful Aspose for .NET APIs directly from NuGet repository. Please see the detailed release notes in order to get an idea about what is new and what has been fixed with this version of Aspose.Cells for .NET. The release notes also list any changes made to the public API such as added, renamed, removed or deprecated members (if any) as well as any non-backward compatible change made to Aspose.Cells for .NET.

Protect VBA (Visual Basic for Applications) Project of Excel Workbook with Password and Lock it for Viewing

Aspose.Cells now supports the feature of protecting the VBA (Visual Basic for Applications) Project of Excel Workbook and locking it for viewing. Besides, you can also find if an existing VBA project is already protected and locked for viewing. Please see these articles for a reference.

The following code snippet demonstrates how to protect your Excel Workbook VBA Project dynamically using Aspose.Cells and lock it for viewing.


//Load your source Excel file.
Workbook wb = new Workbook("samplePasswordProtectVBAProject.xlsm");
 
//Access the VBA project of the workbook.
Aspose.Cells.Vba.VbaProject vbaProject = wb.VbaProject;
 
//Lock the VBA project for viewing with password.
vbaProject.Protect(true, "11");
 
//Save the output Excel file
wb.Save("outputPasswordProtectVBAProject.xlsm");

Specifying Sort Warning While Sorting Data

Aspose.Cells already supports Data Sorting, however earlier you could not sort your textual data as numerical data. For this purpose, Aspose.Cells implemented the DataSorter.SortAsNumber property. Whenever you sort textual data that looks like a number, MS-Excel shows this warning. DataSorter.SortAsNumber property implements this MS-Excel warning.

Please see this article for more help relating to this topic.

Specifying DBNum Custom Pattern Formatting

Aspose.Cells supports the DBNum custom pattern formatting. For example, if your cell value is 123 and you specify its custom formatting as [DBNum2][$-804]General then it will be displayed like 壹佰贰拾叁. You can specify custom formatting of your cell using Cell.GetStyle() method and Style.Custom attribute.

Other Enhancements and Fixes

Aspose.Cells for .NET 17.4.0 has enhanced its core for more stability as well as fixed many critical bugs. Moreover, there are numerous minor enhancements in order to improve the overall usage of the API. A few of the worth mentioning enhancements are as follow.

  • Set Column Header ToolTip.
  • Sparklines disappear after re-saving and rendering to PDF.
  • Formatting error inside shapes texts when Excel is converted to PDF.
  • VbaProject.Sign causes an exception.
  • Re-adding a picture to the same XLS throws a Null Reference error.

Furthermore, in this release, we have fixed several other issues. For example, issues around reading/writing MS Excel file formats, manipulating Pivot Tables, applying formatting to cells, manipulating Ole Objects and shapes, rendering and manipulating charts, rendering HTML to Excel and vice versa, rendering images from Excel worksheets, rendering images files from charts and exporting Excel workbooks to PDF format have been resolved. The formula calculation engine is enhanced too in the new release.

Changes to the Public API

This version of Aspose.Cells for .NET has made some changes to the Public API. A few of the worth mentioning changes are as follow:

  • VbaProject.Protect(bool islockedForViewing,string password) method is added.
  • VbaProject.IsProtected property is added.
  • VbaProject.IslockedForViewing property is added.
  • CopyOptions.ExtendToAdjacentRange property is added.
  • DataSorter.SortAsNumber property is added.

Aspose.Cells for .NET Resources

The resources, you may need to accomplish your tasks: