Hi,
I am trying to set the style for the cell and it doesn’t seem to work. This is the sample I have taken from the documentation and trying to work on. But the sample doesn’t seem to work. Just wanted to make sure I am doing the right thing. I am using Aspose.Cells version 7.3.3.0
//Create a workbook.
Workbook workbook = new Workbook();
//Create a new style object.
Style style = workbook.CreateStyle();
//Set the number format.
style.Number = 14;
//Set the font color to red color.
style.Font.Color = System.Drawing.Color.Red;
//Name the style.
style.Name = “Date1”;
Worksheet ws = workbook.Worksheets[0];
//Get the first worksheet cells.
Aspose.Cells.Cells cells = ws.Cells;
//Specify the style (described above) to A1 cell.
cells[“A1”].SetStyle(style);
//Create a range (B1:D1).
Range range = cells.CreateRange(“B1”, “D1”);
//Initialize styleflag object.
StyleFlag flag = new StyleFlag();
//Set all formatting attributes on.
flag.All = true;
//Apply the style (described above)to the range.
range.ApplyStyle(style, flag);
//Modify the style (described above) and change the font color from red to black.
style.Font.Color = System.Drawing.Color.Black;
//Done! Since the named style (described above) has been set to a cell and range,
//the change would be Reflected(new modification is implemented) to cell(A1) and //range (B1:D1).
style.Update();
//Save the excel file.
for (int i = 2; i <= 10;i++ )
{
ws.Cells[3, i].PutValue(“HHello”);
}
//Saving the Excel file
workbook.Save(“C:\book1.xls”);