Hi Laurence
In VS.NET, the ASPOSE.CELLS properties tells me that the version is 4.0.1.0 and the runtime version v1.0.3705. Using the default cell style does not solve the problem. The actual code I am trying to get to work (default gridlines in worksheet, no gridlines when printed) is as follows:
private void btnGridStyle_Click( object sender, EventArgs e )
{
Workbook wb = new Workbook();
Aspose.Cells.Style defaultStyle = wb.DefaultStyle;
Color styleColor1 = Color.FromArgb( 50, 120, 220 );
Style cellStyle = null;
int index = wb.Styles.Add();
cellStyle = wb.Styles[index];
cellStyle.Name = "Style1";
wb.ChangePalette( styleColor1, 1 );
cellStyle.ForegroundColor = styleColor1;
cellStyle.Pattern = BackgroundType.Solid;
cellStyle.HorizontalAlignment = TextAlignmentType.Left;
cellStyle.VerticalAlignment = TextAlignmentType.Bottom;
cellStyle.Font.Name = "Arial";
cellStyle.Font.Size = 12;
cellStyle.Font.Color = Color.Black;
cellStyle.Font.IsBold = true;
cellStyle.Font.IsItalic = false;
cellStyle.Borders.SetColor( defaultStyle.BackgroundColor );
cellStyle.Borders.SetStyle( CellBorderType.Thin );
cellStyle.Borders.DiagonalStyle = CellBorderType.None;
Color styleColor2 = Color.FromArgb( 123, 66, 23 );
index = wb.Styles.Add();
cellStyle = wb.Styles[index];
cellStyle.Name = "Style2";
wb.ChangePalette( styleColor2, 2 );
cellStyle.ForegroundColor = styleColor2;
cellStyle.Pattern = BackgroundType.Solid;
cellStyle.HorizontalAlignment = TextAlignmentType.Left;
cellStyle.VerticalAlignment = TextAlignmentType.Bottom;
cellStyle.Font.Name = "Arial";
cellStyle.Font.Size = 12;
cellStyle.Font.Color = Color.White;
cellStyle.Font.IsBold = true;
cellStyle.Font.IsItalic = false;
cellStyle.Borders.SetColor( defaultStyle.BackgroundColor );
cellStyle.Borders.SetStyle( CellBorderType.Thin );
cellStyle.Borders.DiagonalStyle = CellBorderType.None;
Color styleColor3 = Color.FromArgb( 255, 255, 255 );
index = wb.Styles.Add();
cellStyle = wb.Styles[index];
cellStyle.Name = "Style3";
wb.ChangePalette( styleColor3, 0 );
cellStyle.ForegroundColor = styleColor3;
cellStyle.Pattern = BackgroundType.Solid;
cellStyle.HorizontalAlignment = TextAlignmentType.Left;
cellStyle.VerticalAlignment = TextAlignmentType.Bottom;
cellStyle.Font.Name = "Arial";
cellStyle.Font.Size = 12;
cellStyle.Font.Color = Color.Black;
cellStyle.Font.IsBold = false;
cellStyle.Font.IsItalic = false;
cellStyle.Borders.SetColor( defaultStyle.BackgroundColor );
cellStyle.Borders.SetStyle( CellBorderType.Thin );
cellStyle.Borders.DiagonalStyle = CellBorderType.None;
Range range = wb.Worksheets[0].Cells.CreateRange( 0, 0, 1, 1 );
range.Style = wb.Styles["Style1"];
wb.Worksheets[0].Cells[0, 0].PutValue( "Style 1" );
range = wb.Worksheets[0].Cells.CreateRange( 0, 1, 1, 1 );
range.Style = wb.Styles["Style2"];
wb.Worksheets[0].Cells[0, 1].PutValue( "Style 2" );
range = wb.Worksheets[0].Cells.CreateRange( 1, 0, 1, 1 );
range.Style = wb.Styles["Style3"];
wb.Worksheets[0].Cells[1, 0].PutValue( "Style 3" );
range = wb.Worksheets[0].Cells.CreateRange( 1, 1, 1, 1 );
range.Style = wb.Styles["Style3"];
wb.Worksheets[0].Cells[1, 1].PutValue( "Style 3" );
wb.Save( "c:\\aspose.xls", FileFormatType.Default );
}
Thanks
Alan