Free Support Forum -

Setting cell range borders using Aspose.Cells Cloud SDK for .NET C#

We are trying to add black borders to a cell range using the .NET SDK with the cloud API, but unsuccessfully. Here is our code:

var color = new Color()
    A = "255",
    B = "0",
    G = "0",
    R = "0"
var border = new Border()
    BorderType = "BottomBorder",
    Color = color,
    LineStyle = "Thick"

var style = new Style()
    BorderCollection = new List<Border>() { border },
_cellsApi.PostUpdateWorksheetRangeStyle( cloudName, "Sheet1", "b3:f3", "", "", style );

Any pointers on how to add borders? We could not find any examples from the documentation, nor is there a test case for this scenario in the .NET SDK GitHub repository.


Following C# code will add black border to a cell range (B3:F3):

string name = "Book1.xlsx";
string sheetName = "Sheet1";
RangeSetOutlineBorderRequest rangeOperate = new RangeSetOutlineBorderRequest();
rangeOperate.BorderEdge = "BottomBorder";
rangeOperate.BorderStyle = "Thick";
rangeOperate.BorderColor = new Color();
Range range = new Range();
range.ColumnCount = 5;
range.FirstColumn = 1;
range.FirstRow = 2;
range.RowCount = 1;
rangeOperate.Range = range;
string folder = TEMPFOLDER;
UpdateDataFile(folder, name);
var response = instance.CellsRangesPostWorksheetCellsRangeOutlineBorder(name, sheetName, rangeOperate, folder);  

The example is using
POST /cells/{name}/worksheets/{sheetName}/ranges/outlineBorder API.

Please make sure you are using our revamped .NET SDK not the deprecated .NET SDK. The relevant unit test is given here.