Free Support Forum -

How to retrieve font style info on a subset of data within a cell


Within a cell a string can be partly bold, for example. When extracting the data and style info from the xls I'm not seeing how to retrieve the subset of characters within that cell that have the style applied.

We know that using the characters function we can set the style for a subset of characters within the cell when creating an xls file. However its not clear how to retrieve the style info from the xls file if it is applied to only part of the data in a cell.

We are using an older version of aspose cells (v2) and are converting to v7. If possible can you describe how to achieve this in both versions?



Hi Denise,

Thanks for your posting and using Aspose.Cells.

You can get/set the formatting of selected characters of the cell. Please check this article that explains how to do this using Aspose.Cells API for your reference.

( )

Thanks Shakeel. This article explains how to set a subset of the characters in a cell with a particular style and save that workbook object in an excel file. What we are trying to achieve is the get the style info from the cell for a subset of characters.

For example, we upload an xls file and use Aspose Cells API to transform it into the WorkBook object. From there we use the Aspose Cells API to retrieve the data and meta/style data from that file. If in one of the cells there is a string that is partly bold, we would like to receive that info. How can we do this without knowing the startIndex and length of the subset of characters? Is this possible?



Hi Denise,

Thanks for your feedback and using Aspose.Cells.

Please use the Cell.getCharacters() method for this purpose. It will return the array of FontSetting objects which will contain the information relating to font like bold, underline, italic, color, size etc.

Please see the see following sample code and its console output. I have also attached the source excel file used in this code for your reference.


Workbook workbook = new Workbook(“source.xlsx”);

Worksheet worksheet = workbook.getWorksheets().get(0);

Cell cell = worksheet.getCells().get(“A1”);

FontSetting[] fntSettings = cell.getCharacters();


Console Output
com.aspose.cells.Color@ff0000 //it means red color