Border colors

For some reason when I try to set a border color it always stays as black.

oSheet.Cells(“M20”).Style.Borders(BorderType.BottomBorder).Color = Color.Black

…produces the same result as…

oSheet.Cells(“M20”).Style.Borders(BorderType.BottomBorder).Color = Color.Orange

The borders are ALWAYS blck, no matter what color I try to use.

Any suggestions?

I further testing I’ve found that nothing works when I use Color.xxx i.e. no borders, fonts, background colors etc are changed.

Is this because I’m still using a trial version?

Please check Color and Palette for reference.

I am using standard colors that are in the Excel palette.

i.e. Color.Red and Color.Orange are standard colors that are not working in my formatting.

The link you gave me takes me to another page that has a link to a standard color palatte. This link is broken!

Color.Red is standar color but Color.Orange is not.

Please check the document on applying styles on cells:
Applying Styles on Cells

for reference.

If you still cannot figure it out, could you please post more of your code here? And which version of Aspose.Excel are you using?

Ok, working now that I’ve added Orange to the palette.
I thought Orange was a standard color.

Thanks.

@mecED,
Aspose.Excel is discontinued and no more available now. It is replaced by Aspose.Cells that is an advanced version and contains support for the latest features in different versions of MS Excel. You can set styles of the border using this new product including color as demonstrated in the following sample code.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Obtaining the reference of the first (default) worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];

// Accessing the "A1" cell from the worksheet
Aspose.Cells.Cell cell = worksheet.Cells["A1"];

// Adding some value to the "A1" cell
cell.PutValue("Visit Aspose!");

// Create a style object
Style style = cell.GetStyle();

style.Font.Name = "Arial";
style.Font.IsBold = true;
style.Font.IsItalic = true;
style.Font.Color = Color.Red;

// Setting the line style of the top border
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thick;

// Setting the color of the top border
style.Borders[BorderType.TopBorder].Color = Color.Orange;

// Setting the line style of the bottom border
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thick;

// Setting the color of the bottom border
style.Borders[BorderType.BottomBorder].Color = Color.Orange;

// Setting the line style of the left border
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thick;

// Setting the color of the left border
style.Borders[BorderType.LeftBorder].Color = Color.Orange;

// Setting the line style of the right border
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thick;

// Setting the color of the right border
style.Borders[BorderType.RightBorder].Color = Color.Orange;

// Apply the border styles to the cell
cell.SetStyle(style);

worksheet.AutoFitColumns();

// Saving the Excel file
workbook.Save("book1.out.xlsx");

For more information about applying styles on cells, follow the link below:
Applying Styles on Cells

The free trial version of this new product can be downloaded here:
Aspose.Cells for .NET (Latest Version)

A detailed solution is available here which can be used for testing different features of this product.