Update designed textbox

Hello,

I’m trying to update (add chars to the end of text) currently placed and designed textbox in my template. The text inside the textbox has a different styles so it’s impossible to get style and apply it after.

See attached example.
I try edit both TextBox and Shape object:

Shape tBox = worksheet.Shapes[“TB1”];
tBox.Text += " lalala";
- or -
TextBox tBox = worksheet.TextBoxes[“TB1”];
tBox.Text += " lalala";

but result is the same.
Could you, please, help me to understand, what am I doing wrong?

Regards,
Jek

Hi,

Thanks for your posting and using Aspose.Cells.

It is working good in the latest version. I have tested this issue with the following sample code. Please check the sample excel file used in this code and the output excel file generated by the code for your reference.


Latest Version Links:

Aspose.Cells for .NET v17.1.7 (.NET 2.0) compiled in .NET Framework 2.0.
Aspose.Cells for .NET v17.1.7 (.NET 4.0) compiled in .NET Framework 4.0.


C#
Workbook wb = new Workbook(“sample.xlsx”);
Worksheet worksheet = wb.Worksheets[0];

Shape tBox = worksheet.Shapes[0];
tBox.Text += " lalala";

wb.Save(“o.xlsx”);

Hello,

Thank you for such a quick response.
The main idea is a number of different fonts in textbox.
Attaching sample file and o.xlsx - a result of your code using the last version, attached by you.

Thanks,
Jek

Hi,


Thanks for your posting and using Aspose.Cells.

We were able to observe this issue and logged it in our database for a fix.

This issue has been logged as

  • CELLSNET-45083 - Appending text to textbox makes lose the formatting of the textbox

Thank you.
Do you have an idea when the fix will be available?

Hi,


Thanks for your posting and using Aspose.Cells.

Your issue is logged just now. So please wait at least 3-7 working days before you ask for ETA. In case, the fix is available sooner, we will let you know asap.

Hi again,


Please use the Shape.TextBody property to append contents to Textbox’s text. Please check the following piece of code and give it a try on your end.

C#

Workbook wb = new Workbook(path + “sample.xlsx”);
Worksheet worksheet = wb.Worksheets[0];
Shape tBox = worksheet.Shapes[0];
tBox.TextBody.AppendText(" lalala");
wb.Save(path + “dest.xlsx”);

Hi,
Thank you for your answer.
It works ok for me.
Good job.

Regards,
Jek

Hi,


Good to know that your issue is sorted out by the suggested code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.