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

Free Support Forum - aspose.com

Rich text (rtf) in TextBox

I need to create a TextBox on a worksheet, but the data is a ‘rtf’ text (for have bold and color word).
I see that my currently version of aspose.cell (1.9.4) have this functionnality :
"Supports to add rich text for shapes such as Arc, Oval, Rectangle, Comment, TextBox "

I don’t found any exemple.
The ‘TextBox’ class has only one method to set data :

setContent(java.lang.String content)

Sets the content of textbox.

Can anymore has an exemple to set a rtf text into a TextBox ?




Yes, Aspose.Cells for Java supports rich text formatting for shapes including TextBox control. Please use TextBox.setCharacters() method for your need.

May the following sample code help you for your need, kindly consult it.

Sample code:

//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the book.
Worksheet worksheet = workbook.getWorksheets().getSheet(0);
//Add a new textbox to the collection.
int textboxIndex = worksheet.getTextBoxes().add(2, 1,200, 160);
//Get the textbox object.
com.aspose.cells.TextBox textbox0 = worksheet.getTextBoxes().get(textboxIndex);
//Fill the text.
textbox0.setContent("ASPOSE______The .NET & JAVA Component Publisher!");
Font myfont = new Font();
textbox0.setCharacters(0,6, myfont);
//Save the excel file.

Thank you.

thank for your quick reply.
The setCaracters is usefull, but it’s not really that i need.
In fact, it’s the same example that the ‘Quick Reply’ of your forum.
The text on my post is written on RTF and posted.

My request is to put a given text, into a TextBox cell with Aspose.Cell for Java, not to writte for scratch a text into a TextBox.

have you a example?




Hi Val,

Well, I 'm afraid we do not support to insert the rtf directly, you have to convert rtf text to decode it to simplified text by yourself and then use TextBox.setCharacters() method to do the job.

Thank you.

thank for your answers, it’s seems to be a bit complicated for a little functionality.
That’s right that a text box doesn’t contains true rtf text so.
I will find a another pretty solution.