Multiple Styles (with size ) within a Single Cell

Hi,

I’m using excel 3.3.0.0

and when try the following
Cell.Characters(0,4).Font.IsBold = true;
Cell.Characters(0,4).Font.Size = 8;

It is setting the font to bold but the size becomes 10 for that cell

But, if I remove the IsBold Line, setting the font size alone works fine.
Other combinations (IsItalic etc.) seems working fine except the size ?

Can u Check up and let me know…

Thanks,

Gopi

Hi Gopi,

I don’t find this problem. Please try this attached fix.

That version (3.3.3.3) took care of it… Thanks for the quick response.

Gopi

Sorry on my oversight… the problem (bug!) is still there, but I made a workaround which seems working !!

Let say, the cellWidth = 20;
and i want the first 4 characters to be bold.

Cell.Characters(0,4).Font.IsBold = true;

and i want all the charecters to have a font size of 8.

Cell.Characters(0,20).Font.Size = 8;

The above line doesn’t work. It puts size 10 on the cell.

Instead, if I do this…
Cell.Characters(0,4).Font.IsBold = true;
Cell.Characters(0,4).Font.Size = 8;
Cell.Characters(5,20).Font.Size = 8;

It works !

Anyother way, you touch this, either it changes to font 10, or the Font Bold is lost
Pls. check. It is not urgent (!) on our side, since it works…

Thanks,
Gopi

Hi Gopi,

It’s not a bug. Your workaround is the right way to set this multi-style cell.

OK. Thanks for the Info. The very nature that I have to set the font size , that too same size , twice for the same cell, made me to think it as a bug !

Gopi

@vgopinath,
Aspose.Cells has replaced Aspose.Excel that is discontinued and no more available. You can set multiple styles within a single cell using Aspose.Cells as demonstrated in the following sample code.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Obtaining the reference of the first(default) worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];

// Accessing the "A1" cell from the worksheet
Cell cell = worksheet.Cells["A1"];

// Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!");

// Setting the font of selected characters to bold
cell.Characters(6, 7).Font.IsBold = true;

// Setting the font color of selected characters to blue
cell.Characters(6, 7).Font.Color = Color.Blue;

// Saving the Excel file
workbook.Save(dataDir + "book1.out.xls");

For more details about data formatting, refer to the following article:
Data Formatting

You can download the latest trial version here:
Aspose.Cells for .NET (Latest Version)

Here is a runnable solution which contains variety of examples to test different features of the product.