Other API Samples

Live SpreadsheetGear API Samples

Snippets Borders

Modify cell borders to use various LineWeight, LineStyle and Color values.

IWorkbook workbook = Factory.GetWorkbook();
IWorksheet worksheet = workbook.ActiveWorksheet;
IRange cells = worksheet.Cells;
cells["A1:C10"].Borders.Weight = BorderWeight.Hairline;
cells["A1:C10"].Borders.Color = Colors.Red;
cells["A1:F10"].Borders[BordersIndex.EdgeTop].Weight = BorderWeight.Thick;
cells["A1:F10"].Borders[BordersIndex.InsideVertical].Weight = BorderWeight.Thin;
cells["A1:F10"].Borders[BordersIndex.InsideVertical].LineStyle = LineStyle.Double;
cells["A1:F10"].Borders[BordersIndex.EdgeBottom].Weight = BorderWeight.Thick;
cells["A1:F10"].Value = "Hello";
cells["A1:F10"].HorizontalAlignment = HAlign.Center;
Run This Sample
Render Image

Generate an image representation of the results of this sample, which uses the SpreadsheetGear.Drawing.Image class to convert ranges, charts and shapes to images.


Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.