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

How to only set a bottom border for a range

Hi,

I am trying to apply a border to the bottom edge of a range of cells using the following code:

rBorder = wsPage.Range[iRow, iCol, iRow, maddCol];
rBorder.CellStyle.Borders.LineStyle = ExcelLineStyle.Thin;
rBorder.CellStyle.Borders[ExcelBordersIndex.DiagonalDown].Color = ExcelKnownColors.None;
rBorder.CellStyle.Borders[ExcelBordersIndex.DiagonalUp].Color = ExcelKnownColors.None;
rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeLeft].Color = ExcelKnownColors.None;
rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeRight].Color = ExcelKnownColors.None;
rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.None;
rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Black;

But I get all borders (top, bottom, left, right, diagonals) appearing, even through I specifically set the color of the other borders to None. Please see the attached Spreadsheet for an example of my output.

Any ideas?

Thanks,
Mark



BorderExample_f5289943.zip

1 Reply

JB John Bowlin Bosco K Syncfusion Team August 9, 2011 05:10 AM UTC

Hi Mark,

Thank you very much for your interest in Syncfusion Products.

While setting the color of specified border to None, the automatic color has been set to that particular border. To set the border to invisible, the line style property of borders must be set to None. To illustrate this, we have created a sample in which bottom border alone has been set by specifying its border line style and the sample has been attached below for your reference. Please find the sample and let me know your feedback.

Sample Link:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=BorderTestSample-1790266587.zip

Code Snippet[C#]:

rBorder = wsPage.Range[iRow, iCol, iRow, maddCol]; rBorder.CellStyle.Borders[ExcelBordersIndex.DiagonalDown].LineStyle = ExcelLineStyle.None; rBorder.CellStyle.Borders[ExcelBordersIndex.DiagonalUp].LineStyle = ExcelLineStyle.None; rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.None; rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.None; rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.None; rBorder.CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;

Please let us know if you need any further clarifications.

Regards,
Pauline Bosco


Loader.
Live Chat Icon For mobile
Up arrow icon