We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Validate name for Named Range in .NET

Hi,

I am trying to find a way to create valid Named Ranges, but I have encountered an issue:
Aspose silently creates named ranges with invalid names (for example names that contains spaces, or unallowed characters: '-', '+', '*'), which will in turn make the Excel workbook invalid. Is there a way in Aspose.Cells to find if a string is valid for a range's name - before I get to create the namedrange?
This is how I create the range:

var range = worksheet.Cells.CreateRange(firstRow, firstColumn, totalRows, totalColumns);
range.Name = myNamedRange;

Thank you,
Ruxandra

Hi Ruzandra,

Thank you for contacting Aspose support.

I am able to verify that the latest revision of Aspose.Cells for .NET 8.5.2.1 silently generates a corrupted spreadsheet when the name of the range has invalid characters. However, I was not able to find a suitable API to validate the range names before setting them therefore a feature request with Id CELLSNET-43858 has been logged for the product team’s review. Please allow us some time to properly analyze the scenario and get back to you with updates in this regard.

C#

var workbook = new Workbook();
var cells = workbook.Worksheets[0].Cells;
var range = cells.CreateRange(0, 0, 10, 10);
range.Name = “+123A”;
workbook.Save(“D:/output.xlsx”);//Saves a corrupted spreadsheet

Hi,


Please try our latest version/fix: Aspose.Cells for .NET v8.5.2.2

We have fixed your issue now.

Let us know your feedback.

Thank you.