Interface IBorders
A collection of four Border objects that represent the four borders of a Range or Style object.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface IBorders : IEnumerable, IParentApplication
Properties
Color
Declaration
ExcelKnownColors Color { get; set; }
Property Value
Type |
---|
ExcelKnownColors |
Remarks
Examples
The following code illustrates how to set color from ExcelKnownColors enumeration to all the IBorder in the IBorders collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["C2"].Text = "Sample";
worksheet["D2"].Text = "text";
worksheet["C3"].Text = "in";
worksheet["D3"].Text = "cell";
//Set borders
IBorders borders = worksheet["C2:D3"].Borders;
//Set color
borders.Color = ExcelKnownColors.Red;
//Set line style
borders.LineStyle = ExcelLineStyle.Thick;
//Save and dispose
workbook.SaveAs("CellFormats.xlsx");
workbook.Close();
}
ColorRGB
Declaration
Color ColorRGB { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
Examples
The following code illustrates how to set RGB color from System.Drawing.Color structure to all the IBorder in the IBorders collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["C2"].Text = "Sample";
worksheet["D2"].Text = "text";
worksheet["C3"].Text = "in";
worksheet["D3"].Text = "cell";
//Set borders
IBorders borders = worksheet["C2:D3"].Borders;
//Set color
borders.ColorRGB = System.Drawing.Color.Red;
//Set line style
borders.LineStyle = ExcelLineStyle.Thick;
//Save and dispose
workbook.SaveAs("CellFormats.xlsx");
workbook.Close();
}
Count
Declaration
int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to access Count
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Set borders
IBorders borders = worksheet["C2"].Borders;
//Check count
Console.Write(borders.Count);
//Save and Dispose
workbook.SaveAs("CellFormats.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//6
Item[ExcelBordersIndex]
Returns a IBorder object that represents one of the IBorders of either a IRange of cells or a IStyle.
Declaration
IBorder this[ExcelBordersIndex Index] { get; }
Parameters
Type | Name | Description |
---|---|---|
ExcelBordersIndex | Index |
Property Value
Type |
---|
IBorder |
Examples
The following code illustrates how to access IBorder using ExcelBordersIndex from the IBorders collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["C2"].Text = "Sample";
worksheet["D2"].Text = "text";
worksheet["C3"].Text = "in";
worksheet["D3"].Text = "cell";
//Set borders
IBorders borders = worksheet["C2:D3"].Borders;
//Set color
borders.Color = ExcelKnownColors.Red;
//Set line style
borders.LineStyle = ExcelLineStyle.Thick;
//Set diagonal line visibility
borders[ExcelBordersIndex.DiagonalDown].ShowDiagonalLine = false;
borders[ExcelBordersIndex.DiagonalUp].ShowDiagonalLine = false;
//Save and dispose
workbook.SaveAs("CellFormats.xlsx");
workbook.Close();
}
LineStyle
Returns or sets the line style for the IBorder. Read / write ExcelLineStyle.
Declaration
ExcelLineStyle LineStyle { get; set; }
Property Value
Type |
---|
ExcelLineStyle |
Examples
The following code illustrates how to set LineStyle
to all the IBorder in the IBorders collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Set borders
IBorders borders = worksheet["C2:D3"].Borders;
//Set color
borders.Color = ExcelKnownColors.Red;
//Set line style
borders.LineStyle = ExcelLineStyle.Thick;
//Save and dispose
workbook.SaveAs("CellFormats.xlsx");
workbook.Close();
}
Value
Synonym for Borders.LineStyle. Read / write.
Declaration
ExcelLineStyle Value { get; set; }
Property Value
Type |
---|
ExcelLineStyle |
Examples
The following code illustrates how to set Value
to all the IBorder in the IBorders collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Set borders
IBorders borders = worksheet["C2:D3"].Borders;
//Set color
borders.Color = ExcelKnownColors.Red;
//Set line style
borders.Value = ExcelLineStyle.Thick;
//Save and dispose
workbook.SaveAs("CellFormats.xlsx");
workbook.Close();
}