How to add formatting to specific part of text

Hi,

I am populating my text into the excel sheet cells from a xml configuration file.

I required to some confitional formating. For example, the contect tag inside my xml contains a value "Hello there, this is a sample text".

I want sample text to appear in bold.

Does, Cell.PutValue allows any conditional tags e.g. (the way we do in HTML). So if I put "Hello there, this is a sample text" cell would automatically display sample text in bold.

I understand, this is not html, however; is there any work around with aspose.cells?

Thanks for your help in advance.

Regards, Vinay

Hi,

I think you may use Cell.HtmlString property to implement it, see the following sample code:

Aspose.Cells.Workbook xlWorkbook = new Aspose.Cells.Workbook();
Aspose.Cells.Worksheet xlWorkSheet = xlWorkbook.Worksheets[0];
Cells cells = xlWorkSheet.Cells;
cells[“A1”].HtmlString = “Hello there, this is a sample text”;
xlWorkbook.Save(“e:\test\myfile.xls”);



Thank you.

I wish I could. HtmlString property is readonly. Any other alternative?

Hi,
Please try the attached latest version/fix, the Cell.HtmlString property is read and write now.

Thank you.

Is this fix going to be part of your latest installer?

We are already using Aspose library in our project. However currently I am evaluating your latest version.

Just wanted to know, If this will required new licence to be purchased from Aspose? If not; why does the new one throws free upgrade error?

Hi,

You may use our latest version/fix v4.8.2.9 if your subscription allows this, you may open your license file into notepad and check the expiry date. When you purchase the license of a product, you are eligible to use versions / bug fixes of the products that are released in the next whole year. But if a version/fix is released after your subscription expiry date, you need to upgrade your subscription then.

So, could you check your subscription expiry date mentioned in your license file…

Moreover, for upgrading your subscription, please contact Aspose.Purchase forum.

Thank you.

I tried HtmLString property using the new dll u sent and it worked.

I am facing a new problem here.

When I use, PutValue method of the cell class... excel sheet keeps its formatting however with HtmlString property entire formatiing is over ridded.

Is there any flag available whcih allows the existing formatting to be kept as it is?

So for example, let say a cell was already formatted in the existing excel sheet to have all the text in bold and I want to make a perticular text in the string to appear italic underlined.

E.G

Hi Dave, How are you today? Using HTML I would like to go for Hi Dave, How are you today.

I can ofcourse add a bold tag around the text to make it bold. However entire formatting is already provided in the excel template and I don't want to disturb it and write any addition code to achieve this.

Is there anyway, I can achieve this?

Thanks, Vinay

Hi,

Well, you need to choose one way. Either you should use Cell.HtmlString to provide html to format your data in the cell or you may use Cell.PutValue() method to insert text in the cell first and then use apply Style formatting for your requirement, see the document for reference: Dealing with Font Settings

By the way, we are not completely sure about your requirement, could you elaborate and give us more details. Do you want to set an html string and keep the text bold? Please provide us further information. We can look into it soon.

Thank you.

To summarise a very basic requirement.

We have a excel file, which multiple sheets into it.

Each sheet has its internal formatting defined. So lets consider cell A1, the saved file has some text in it which is formatted to bold already.

Now using aspose, if I do a cell["A1"].HtmlString = strValue the bold is replaced by italic.

if I use, cell["A1"].putvalue("strValue") the excel sheet cell A1 display value strValue (All in bold).

So, difference between both of these methods is, putValue method doesnot effect the existing formatting applied to the excel sheet cell however HtmlString does. What I want is, HtmlString method should not affect the existing formatting applied to the excel sheet cell. So using HtmlSting method should give me a output strValue i.e. Both italic(addition formatting applied using HTMLString) and bold(original formatting which was already there on the excel cell) Hope this clarifies the requirement.

Can you please provide a flag with this existing method which can take care of this? This flat should notify method that, existing formatting has to be kept or not!

Hi,

Thanks for providing us details.

We have logged your feature request into our issue tracking system with an issue id: CELLSNET-14974. We will look into it and get back to you soon.

Thank you.

Hi,

Please try the attached version, we have enhanced the API e.g adding additional text/formatting and keeping the existing formatting
according to your requirement.

Thank you.

how should I use it? Same use HtmlString? By the way, I did not recieve the attachement on my email. I can see it in the forum though.

Thanks by the way, it has been an awsome support from you guys.

Hi,

Yes, it will work the same way. We have enhanced the API in such a way that the existing formatting would be retained.

Thank you.

The issues you have found earlier (filed as CELLSNET-14974) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.