Change Cells Alignment with Existing Formatting Intact in Excel using C# .NET

Aspose.Cells for .NET logo

We are pleased to announce the release of Aspose.Cells for .NET v18.7. Please check the document on how to install Aspose for .NET APIs directly from NuGet repository. In this release, we have added some utility features for the users. Moreover, we included important fixes and other enhancements in the release. Please check the release notes in order to get an idea about what is new and what has been enhanced or fixed with this revision of Aspose.Cells for .NET.

Change Cells Alignment and Keep Existing Formatting

If you need to change the alignment of multiple cells but also want to keep existing formattings intact, Aspose.Cells allows you to do that using the StyleFlag.Alignments property. Please note, StyleFlag object is passed as a parameter to Range.ApplyStyle() method which actually applies the formatting to your desired range of cells. The following sample code loads the sample Excel file, creates the range and center aligns it horizontally and vertically and keeps the existing formatting intact.

Please see the following article for more detail on this topic for your reference.

Find Maximum Rows and Columns in XLS and XLSX

For your information, there are a different number of rows and columns supported by different MS Excel file formats. For example, XLS supports up to 65536 rows and 256 columns while XLSX supports 1048576 rows and 16384 columns. If you want to know how many rows and columns are supported by a given format, you can use Workbook.Settings.MaxRow and Workbook.Settings.MaxColumn properties. Please see the following article for more detail on this topic for your reference:

Specify Author while Write Protecting Workbook

You can specify author name while write protecting your workbook using Aspose.Cells API. Please use Workbook.Settings.WriteProtection.Author property for this purpose. Please see the following article for more detail on this topic for your reference:

Encrypt/Decrypt an ODS File

Aspose.Cells allows you to encrypt and decrypt an ODS file. Decrypted ODS file can be opened both in MS Excel and OpenOffice, however encrypted ODS file can only be opened by OpenOffice after providing the password. Excel cannot open the encrypted ODS file and may raise warning message. For encrypting an ODS file, load the file and set the WorkbookSettings.Password value to the actual password before saving it. Please see the following article for more detail on this topic for your reference:

Other Enhancements and Fixes

There are some other enhancements included and a few exceptions handled in the new release for the users. A few of the worth mentioning features and other improvements are as follows.

  • Round images become square images in the output PDF.
  • Support Pivot Table Slicers.
  • Using “List<dynamic>” or “List<ExpandoObject>” as DataSource for importing data into worksheet.
  • Handled “Index out of range” exception in SheetRender.ToImage method.
  • Exception: “Invalid parameters for function iferror….” when loading an Excel file.
  • Invalid PatternType string value exception while loading a file.

Changes to the Public API

The following is a list of any changes made to the public API such as added, renamed, removed or deprecated members as well as any non-backward compatible change made to Aspose.Cells for .NET:

  • Adds enum StyleFlag.Alignments, it represents all the settings of alignment.
  • Adds WorkbookSettings.MaxRow and WorkbookSettings.MaxColumn properties, these attributes gets the max row and column indexes of the workbook.
  • Adds WriteProtection.Author property, it gets and sets the author of the write protection.

Aspose.Cells for .NET Resources

The resources, you may need to accomplish your tasks: