Search code examples
excelaxaptadynamics-ax-2009

Rotate text in Excel using axapta X++


I need to display the output from Axapta in Excel in the following manner. Excel View

Kindly assist.


Solution

  • I have added the following method in my base Excel Class and am able to get the solution.

    public void setCellProperty(int _r1, int _c1,int _r2, int _c2,
           int _orientation = 0,
           int _horizontalAlignment = 1,
           int _verticalAlignment = 1,
           boolean _wrapText = False,  
           boolean _addIndent = False,
           int     _indentLevel = 0,
           boolean _shrinkToFit = False,
           int     _readingOrder = 0, 
           boolean _mergeCells = False)
    {
        COM cell1,cell2;
        str range;
        ;
        cell1        = null;
        cell2        = null;
        cell1 = worksheet.cells();
        this.variant2COM(cell1, cell1.item(_r1,_c1));
        cell2 = worksheet.cells();
        this.variant2COM(cell2, cell2.item(_r2,_c2));
        range   =strfmt("%1:%2",cell1.address(),cell2.address());
        cellRange   =worksheet.Range(range);
        cellRange.Mergecells(_mergeCells); 
        cellRange.IndentLevel(_indentLevel);
        cellRange.AddIndent(_addIndent);
        cellRange.Orientation(_orientation);
        cellRange.VerticalAlignment(_verticalAlignment);
        cellRange.HorizontalAlignment(_horizontalAlignment);
    }
    

    the variable _orientation decides the inclination, for the case above pass orientation=90