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

Free Support Forum - aspose.com

Equivalent of XlColorIndex.xlColorIndexAutomatic border color in Aspose.Cells

I am just completing the conversion of out App to communicate with Excel using Aspose.Cells instead of Excel Automation. In Excel Automation I can set the Border color on a Excel range to
xlColorIndexAutomatic from the XlColorIndex Enumeration. Is there the equivalent of this in Aspose Cells. I am using Range.SetOutlineBorder() currently so set other border colors and this is working fine.

Hi David,

Thank you for contacting Aspose support.

I am afraid, there is no equivalent for the XlColorIndex.xlColorIndexAutomatic in Aspose.Cells APIs therefore you have to explicitly specify the color while adding outline borders to a range of cells.


//Instantiate a new Workbook.
Workbook objBook = new Workbook();
//Get the First sheet.
Worksheet objSheet = objBook.Worksheets[“Sheet1”];

//Put some text into different cells (A2, A4, A6, A8).
objSheet.Cells[1, 0].PutValue(“Hair Lines”);
objSheet.Cells[3, 0].PutValue(“Thin Lines”);
objSheet.Cells[5, 0].PutValue(“Medium Lines”);
objSheet.Cells[7, 0].PutValue(“Thick Lines”);

//Define a range object(A2).
Aspose.Cells.Range _range;
_range = objSheet.Cells.CreateRange(“A2”, “A2”);
//Set the borders with hair lines style.
_range.SetOutlineBorders(CellBorderType.Hair, Color.Black);
//Define a range object(A4).
_range = objSheet.Cells.CreateRange(“A4”, “A4”);
//Set the borders with thin lines style.
_range.SetOutlineBorders(CellBorderType.Thin, Color.Black);
//Define a range object(A6).
_range = objSheet.Cells.CreateRange(“A6”, “A6”);
//Set the borders with medium lines style.
_range.SetOutlineBorders(CellBorderType.Medium, Color.Black);
//Define a range object(A8).
_range = objSheet.Cells.CreateRange(“A8”, “A8”);
//Set the borders with thick lines style.
_range.SetOutlineBorders(CellBorderType.Thick, Color.GhostWhite);

//Save the excel file.
objBook.Save(dir + “ApplyBorders.xls”);