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

Free Support Forum - aspose.com

Unique Name for worksheet

Hi Team,

We have a problem where if we want to have name of worksheet with some special characters(such as * / \ etc) it doesn’t allow us to do so.

Is there a workaround for this, as the special characters are must, if we cant have it as a worksheet name may be we can store it somewhere as worksheet properties, as we do for workbook using document properties?

Thanks.

@siddhanntarora1992,
Aspose.Cells follows similar rules for naming worksheet as by Excel itself. If you try to use these characters(* / ) in the worksheet name using Excel, it does not allow to use these characters. To assist the user for creating valid sheet names Aspose.Cells has provided a utility which gets the proposed worksheet name as an argument and returns the valid name using this proposed string by removing characters which are not allowed in naming the worksheet. Please use this feature to name a worksheet to avoid errors/exceptions.

For example, if you just pass a proposed name, this function will remove invalid characters and replace them with space. Also if name length is more than the standard length (31), that will be truncated.

string validName = CellsHelper.CreateSafeSheetName("Name*AND\\AND/");
Output will be "Name AND AND "

You can also suggest the replace character such which is used instead of space characters while removing the illegal characters.

string validName = CellsHelper.CreateSafeSheetName("Name*AND\\AND/", '_');
Output will be “Name_AND_AND_”

Please give it a try and share the feedback. Also, follow the below link to get more information about naming the worksheets.

Worksheets: Naming Conventions