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

Free Support Forum - aspose.com

Formatting issue in Aspose.cells

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We are using Aspose.cells for .NET to export data to excel.

This is the method[ sheet.Cells.ImportDataTable(dt, true, "A3"); ] used to import data table to excel.

I want to do the following formatting.

1. Want to set the header row style

2. In a decimal field type I want to check for a particular value say -99999 and set ‘N/A’ in place of that value. I can’t directly put ‘N/A’ in data table and import because data table column type is decimal, that’s why once data is imported to excel I want to change -99999 to ‘N/A’.

For header row style I tried a couple of methods like ApplyStyle , ApplyRowStyle, but whatever style I am trying to apply on a header cell or header row ,it applies to entire table, I can’t set only header row style.

Below is sample code given.

Aspose.Cells.Style style1 = cells["A4"].GetStyle();

style1.Font.IsBold = true;

style1.Font.Color = Color.Red;

Row row = workbook.Worksheets[0].Cells.Rows[2];

//Apply the style to it.

row.ApplyStyle(style1, styleFlag);

Any Help appreciated.

Hi,


i) "For header row style I tried a couple of methods like ApplyStyle , ApplyRowStyle, but whatever style I am trying to apply on a header cell or header row ,it applies to entire table, I can’t set only header row style.

Please change your line of code i.e.:
sheet.Cells.ImportDataTable(dt, true, “A3”);
to:
sheet.Cells.ImportDataTable(dt, true, 2,0, false”);
// Choose this overloads and put “false” for the boolean insertRows parameter.

"In a decimal field type I want to check for a particular value say -99999 and set ‘N/A’ in place of that value. I can’t directly put ‘N/A’ in data table and import because data table column type is decimal, that’s why once data is imported to excel I want to change -99999 to ‘N/A’."

Well, I am afraid, there is no direct way to do this and we do not support such logic to change a valid value to N/A while importing a datatable, there would be no valid logic involved too. For your case, I think once we have imported data to fill in the cells, then you have manually search / find your desired values in the cells and replace them accordingly for your custom needs. Please see the document on how to find or search data:
http://www.aspose.com/docs/display/cellsnet/Find+or+Search+Data

Thanks for your understanding!