We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Borders

Is it possible to determine the border properties of a cell, top, left etc from an existing sheet? For instance, I need to get all the border information from a cell on a template sheet then set only the top border of cell of the destination sheet.

1 Reply

MW Melba Winshia Syncfusion Team January 23, 2007 10:42 AM UTC

Hi Bill,

Thanks for your interest in Essential XlsIO.

Yes, it is possible to determine the border properties of a cell.

1) Please refer the following code snippet to set the border [top, bottom, left and right] linestyle.

[C#]

// Setting Border LineStyle - Bottom
sourcesheet.Range["B2"].CellStyle.Borders[ ExcelBordersIndex.EdgeBottom ].LineStyle =ExcelLineStyle.Dash_dot;

// Setting Border Linestyle - Left
sourcesheet.Range["B2"].CellStyle.Borders[ ExcelBordersIndex.EdgeLeft ].LineStyle = ExcelLineStyle.Dash_dot;

// Setting Border Linestyle - Right
sourcesheet.Range["B2"].CellStyle.Borders[ ExcelBordersIndex.EdgeRight ].LineStyle = ExcelLineStyle.Dash_dot;

// Setting Border Linestyle - Top
sourcesheet.Range["B2"].CellStyle.Borders[ ExcelBordersIndex.EdgeTop ].LineStyle = ExcelLineStyle.Dash_dot;

2) Please refer the following code snippet to get the border information from a cell and then set the top border of cell of the destination sheet.

[C#]

//Applying the border linestyle to the destination sheet.

destsheet.Range["B2"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle=sourcesheet.Range["B2"].CellStyle.Borders[ ExcelBordersIndex.EdgeTop ].LineStyle;

Please refer the following sample which implements the above said feature:

Borders.zip

Please take a look and let me know if you have any other questions.

Best Regards,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon