We are encoutering one issue with assigning the sheet name at runtime.
We are fetching the sheet names from one XML and assigning. There is a chance to add some additional characters to the sheet name at runtime based on data
Aspose.Cells component follows MS Excel guidelines in its implementation, therefore you cannot set the sheet name having length greater than 31 characters using Aspose.Cells (all flavors). Moreover, Aspose.Cells API does not provide any means to truncate the sheet name in case the length exceeds the specified limit, instead it throws an appropriate exception as mentioned in your message. I am afraid, you have to write you own custom routines to check the text length before setting it as a sheet name. Similarly, if the text length exceeds the limit, you have to come up with your own custom logic to truncate the text accordingly.
Please feel free to write back in case you have further questions.
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix if possible. Once, we will have some news for you, we will update you in this topic.
This issue has been logged as
CELLSNET-46298 – Create safe sheet names similar to Apache POI
The issues you have found earlier (filed as CELLSNET-46298) have been fixed in Aspose.Cells for .NET v18.9. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi
Sure, you may please try the following sample code for Aspose.Cells for Java and provide feedback.
import com.aspose.cells.CellsHelper;
public class CreateSafeSheetNames {
public static void main(String[] args) throws Exception {
// Long name will be truncated to 31 characters
String name1 = CellsHelper.createSafeSheetName("this is first name which is created using CellsHelper.CreateSafeSheetName and truncated to 31 characters");
// Any invalid character will be replaced with _
String name2 = CellsHelper.createSafeSheetName(" <> + (adj.Private ? \" Private\" : \")", '_');//? shall be replaced with _
// Display first name
System.out.println(name1);
// Display second name
System.out.println(name2);
}
}