I try to using the Aspose.Cells (Version 4.3), I want to set the style to single cell or range, but the all cells style changed!! all cells's style be override.
please test the following code
---------------------------------------------------------------------------------------
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
//Filling some data into the cells
for (int i = 0; i < 50; i++)
{
for (int j = 0; j < 10; j++)
{
cells[i, j].PutValue(i.ToString() + "," + j.ToString());
}
}
//First Style Setting
Aspose.Cells.Style mStyle = workbook.Styles[workbook.Styles.Add()];
mStyle.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
mStyle.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
mStyle.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
mStyle.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
Range range = workbook.Worksheets[0].Cells.CreateRange(0, 0, 50, 10);
range.Style = mStyle;
//add a new style
Aspose.Cells.Style stl5 = workbook.Styles[workbook.Styles.Add()];
//Set the font name.
stl5.Font.Name = "Tahoma";
//Set the font size.
stl5.Font.Size = 10;
//Set font text color.
stl5.Font.Color = Color.Red;
//Set the font bold.
stl5.Font.IsBold = true;
//Set the font italic.
stl5.Font.IsItalic = true;
//Create the style flag struct and specify which formattings
//you want to apply.
StyleFlag flag = new StyleFlag();
flag.FontName = true;
flag.FontSize = true;
flag.FontColor = true;
flag.FontBold = true;
flag.FontItalic = true;
//Create a range of cells for your need.
Range range1 = workbook.Worksheets[0].Cells.CreateRange(4, 3, cells.MaxDataRow - 3, 1);
//Apply the style to cells in the named range.
range1.ApplyStyle(stl5, flag);
//!!!!!! but the all cells style changed!!!!!!!!
//or any single cell's style changed, will changed all cells, why? if don't setting the first style, the problem is not exist!
workbook.Worksheets[0].Cells["A5"].Style.Font.IsBold = true;
workbook.Save("e:\\my_book.xls");
---------------------------------------------------------------------------------------
I just want to change the style of single cell or range, not all cells. pls help me, thanks!!!