Trouble with Styling Borders using Aspose.Cells Cloud PHP SDK

Hi there,

I’m encountering some difficulty when trying to apply borders to cells using the Aspose.Cells Cloud PHP SDK. Despite checking the SDK documentation and various online resources, I’m unsure about the correct values to use for setLineStyle and setBorderType. I haven’t been able to find relevant code samples to validate my approach.

Currently, my borders are not rendering as expected. I’ve attached a screenshot illustrating how the styled cells appear. Could someone guide me on the correct values or provide a sample snippet for setting cell borders?

Here’s the code snippet I’m working with:

    $backgroundColor = new \Aspose\Cells\Cloud\Model\Color();
    // Set the RGB values
    $backgroundColor->setR(217); // Red
    $backgroundColor->setG(217); // Green
    $backgroundColor->setB(217); // Blue

    // Optionally, if the class requires setting alpha (transparency), use setA().
    // Assuming alpha value is 255 (fully opaque), you can set it like this:
    // $backgroundColor->setA(255);

    $borderColor = new \Aspose\Cells\Cloud\Model\Color();
    // Set the RGB values
    $borderColor->setR(0); // Red
    $borderColor->setG(0); // Green
    $borderColor->setB(0); // Blue


    // $borderTypes = ["TopBorder", "BottomBorder", "LeftBorder", "RightBorder"];

    $borderTypes = ["top_border", "bottom_border", "left_border", "right_border"];
    $borders = [];

    foreach ($borderTypes as $borderType) {
        $border = new Border();
        $border->setLineStyle("Solid"); // Line style can be Thin, Medium, Dashed, etc.
        $border->setColor($borderColor);
        $border->setBorderType($borderType); // Set the border type for each edge

        $borders[] = $border; // Add to the borders array
    }

    $style = new \Aspose\Cells\Cloud\Model\Style();
    $style->setForegroundColor($backgroundColor); 
    $style->setPattern("Solid" ); 
    $style->setBorderCollection($borders); // Add all borders to the collection

    print_r($style);

    $request = new PostUpdateWorksheetCellStyleRequest();
    $request->setName( $tempExcelName);
    $request->setSheetName( "Sample");
    $request->setCellName( "H8");
    $request->setStyle( $style);
    $request->setFolder("");
    $request->setStorageName( "");
    $cellResponse = $cellsApi->postUpdateWorksheetCellStyle($request);

    $request = new PostUpdateWorksheetCellStyleRequest();
    $request->setName( $tempExcelName);
    $request->setSheetName( "Sample");
    $request->setCellName( "H9");
    $request->setStyle( $style);
    $request->setFolder("");
    $request->setStorageName( "");
    $cellResponse = $cellsApi->postUpdateWorksheetCellStyle($request);

Any help will be greatly appreciated.
Screen Shot 2023-11-30 at 12.44.28 pm.png (2.1 KB)

@pwsolutionsau ,

I’ve initiated testing and will provide feedback as soon as possible.

@pwsolutionsau,
We have tested and reproduced the issue. Subsequently, we have created a new ticket in our internal issue tracking system. We will address these concerns as soon as possible. If you specifically aim to establish an outer border for the specified range, you may utilize the following API (PostWorksheetCellsRangeOutlineBorder).

    $remoteFolder = "TestData/In";
    $localName = "Book1.xlsx";
    $remoteName = "Book1.xlsx";

    $rangeOperateborderColor = new \Aspose\Cells\Cloud\Model\Color();
    $rangeOperateborderColor->setR(48 ); 
    $rangeOperateborderColor->setG(48 ); 
    $rangeOperateborderColor->setB(48 ); 
    $rangeOperateRange = new \Aspose\Cells\Cloud\Model\Range();
    $rangeOperateRange->setColumnCount(1 ); 
    $rangeOperateRange->setColumnWidth(10.0 ); 
    $rangeOperateRange->setFirstRow(1 ); 
    $rangeOperateRange->setRowCount(10 ); 
    $rangeOperate = new \Aspose\Cells\Cloud\Model\RangeSetOutlineBorderRequest();
    $rangeOperate->setborderEdge("LeftBorder" ); 
    $rangeOperate->setborderStyle("Dotted" ); 
    $rangeOperate->setborderColor($rangeOperateborderColor ); 
    $rangeOperate->setRange($rangeOperateRange ); 
    CellsApiTestBase::ready(  $this->instance,$localName ,$remoteFolder . "/" . $remoteName ,  "");
 
    $request = new PostWorksheetCellsRangeOutlineBorderRequest();
    $request->setName( $remoteName);
    $request->setSheetName( "Sheet1");
    $request->setRangeOperate( $rangeOperate);
    $request->setFolder( $remoteFolder);
    $request->setStorageName( "");
    $this->instance->postWorksheetCellsRangeOutlineBorder($request);

From aspose-cells-cloud-php/test/Api/RangesControllerTest.php at master · aspose-cells-cloud/aspose-cells-cloud-php (github.com)