How to set part of text in cell to bold


#1

Hi,

was wondering how do i set part of a text in a cell to be bold ? i am reading the values from a database.

for eg i read 2 values from the db, and display in excel, something like this in a cell:

title
text

please help


#2

Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/RichText.html .


#3

Hi Laurence,

it worked. but somehow the font is smaller. tried using cell.style.font.size = 12 but still does not work. i tried cell.characters.font.size = 12 but there's this error Unable to cast object of type 'System.String' to type 'Aspose.Excel.ai'.

Also, when i try to use autofitrow on cells that contains carriage return '\n'. it doesn't work too. it will only show the first line. the rest is hidden.

can u help ?


#4

That may be a problem in old version.

Following is my sample code with latest version of Aspose.Cells.

Workbook workbook = new Workbook();
Cell cell = workbook.Worksheets[0].Cells["A1"];
cell.PutValue("Title\ntext");
cell.Style.IsTextWrapped = true;
cell.Characters(0, 5).Font.IsBold = true;
cell.Characters(0, 5).Font.Size = 12;

workbook.Worksheets[0].AutoFitRow(0);

workbook.Save("d:\\test\\abc.xls");

Attached is new Aspose.Cells.dll and output file.


#5

Hi Laurence,

I realised the dll that I used is Aspose.Excel.dll and i have the license for this. Version is 2.9.7.3. i can't use the Aspose.Cells dll as i do not have the license for this. I need to generate thousands of reports and i can't afford to go in and delete the last worksheet that contains the evaluation warning message.

Is there anyway u can get me a hotfix for this version instead?


#6

Could you tell me the expiry date of your license file? I can post an old version of Aspose.Excel for you. However, I think it's better to renew your subscription.


#7

hi

expiry date is 20060301. Do we need to pay to renew?

thanks


#8

Yes, you need to pay to renew.

You can download and try Aspose.Cells v3.7. It's released before 060301 and you can use it without renewal.


#9

help, tried but i am still seeing the Evaluation Copyright warning worksheet


#10

How do you set the license? Please try:

Aspose.Cells.License lic = new Aspose.Cells.License();

lic.SetLicense("d:\\lic\\Aspose.Excel.lic");

Excel excel = new Excel();
Cell cell = excel.Worksheets[0].Cells["A1"];
cell.PutValue("Title\ntext");
cell.Style.IsTextWrapped = true;
cell.Characters(0, 5).Font.IsBold = true;
cell.Characters(0, 5).Font.Size = 12;

workbook.Worksheets[0].AutoFitRow(0);

workbook.Save("d:\\test\\abc.xls");


#11

Smile [:)] thanks so much, it works now.