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

Free Support Forum - aspose.com

Unable to fetch single cell value from CellDataTable to format

Hi Team,

There is a query regarding formatting of particular cell value while using CellDataTable with workbookDesigner and template based approach with smart markers. Issue here we are facing is unable to fetch single cell value from iteration of CellDataTable to format that cell with font styles etc.Could you please provide suggestions on the same which would be greatful for us. Thank you. Let me know if any detailed inputs are required.

Regards

Anitha

Hi Anitha,

Thanks for your posting and using Aspose.Cells.

Could
you please explain your issue with more elaboration? Please provide us
some sample code illustrating your issue. You could also provide us your
actual output and expected output Excel files for reference. You can
created your expected Excel file manually using Microsoft Excel and
provide it to us. It will help us look into your issue precisely and we
will be able to help you asap.

Hi,

Thank you so much for your quick response. Here i am attaching required excels. In attached "Expected Excel" file there are few cells which are red in color based on some conditional flags and i need to achieve this using CellDataTable. I have attached "CodeSnippet" file for the same. I have conditional flgs with me but i dont know how to retrive cell value to format it with styles in my code. Can you suggest any methods to be overriden in ICellsDataTable class.

Please help me out.Thanking you in advance. Let me know if any detailed inuts rae required.

Regards

Anitha

Hi Anitha,

Thanks for your posting and using Aspose.Cells.

We have evaluated your issue and we are afraid, CellDataTable can only hold data and not style information. You cannot merge data and style information together. You will have to do it step by step.

First you will import your data from CellDataTable into your worksheet as you have already done, then after that you will selectively set the style of your desired cells.

Please see the following code, it sets the font color of cell A1 to red. You can select your cells in the same way and set their styles.

I have attached the sample Excel file and the output Excel file generated by the code for your reference

Java


String filePath = “F:\Shak-Data-RW\Downloads\sample.xlsx”;


Workbook workbook = new Workbook(filePath);


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


//Access your desired cell

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


//Set its font color to red

Style style = cell.getStyle();

style.getFont().setColor(Color.getRed());

cell.setStyle(style);


workbook.save(filePath + “.out.xlsx”);