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

Free Support Forum - aspose.com

Apply text formatting inside a cell in Excel worksheet in .NET

Hi, I have some question about characters from cell. If you look my code snippet:

String path = “src/main/resources/aspose/cells/test.xls”;

Workbook workbook = new Workbook();


Worksheets worksheets = workbook.getWorksheets();

Worksheet worksheet = worksheets.getSheet(0);

Cells cells = worksheet.getCells();

Cell cell = cells.getCell(10, 1);

Characters[] charactersArray = cell.getCharacters();

Characters characters = charactersArray[0]; //there is only one

characters.getStartIndex(); // start index is 38

characters.getLength(); // length is 4

Font font = characters.getFont();

font.isBold(); // returns true

My question is why there are just these indexes in characters class when whole cell is in bold?

There is test document in attachment.

Thanks, Ivica.

Hi Ivica,

We will get back to you soon for your inquiry.

Thank you.

Hi Ivica,

I think maybe your template file is not the original one created by Excel, there are those Characters indexes and structure saved in your template and Aspose.Cells just read it out and build it. If this template was created by Aspose.Cells, I think maybe you have invoked Cell.setCharacters on those cells with startIndex=0 and length=value.length, that will bring this result. If your workarounds was not as I assumed, please give us more detail and we will look into it soon.

Hi, can you tell me what do you mean by “template” file, and how can I find it in my document. Document in attachment is created by MS Excel, not via Aspose.Cells.

Thanks, Ivica.

Hi Ivica,

Cell (10, 1) is B11. In this cell, you can see the text is :

Cash provided by operating activities: (1)

The first 38 characters use cell B11's formatting. The font setting is Arial, Bold, 10. And the last 4 characters use another font setting. It's Arial, Bold, 8.

Whole cell's font is bold but the font size is different.