Skip to main content

XlCellRange.FromLTRB(Int32, Int32, Int32, Int32) Method

Returns a XlCellRange object by the indexes of the bounding rows and columns.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v23.2.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public static XlCellRange FromLTRB(
    int left,
    int top,
    int right,
    int bottom
)

Parameters

Name Type Description
left Int32

An integer that is the zero-based index of the left column.

top Int32

An integer that is the zero-based index of the top row.

right Int32

An integer that is the zero-based index of the right column.

bottom Int32

An integer that is the zero-based index of the bottom row.

Returns

Type Description
XlCellRange

A XlCellRange object that defines a worksheet range.

Remarks

Tip

To define a range by its reference string, use the XlCellRange.Parse method.

Example

This code snippet creates an IXlFormulaParameter expression from a combination of constants, operators and functions. Constants are transformed into the IXlFormulaParameter objects with the XlFunc.Param method. Operators are static methods of the XlOper object and functions are static methods of the XlFunc object.

When an expression is created, the IXlCell.SetFormula method is used to enter expression into a worksheet cell as the cell formula.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

// Create the total row using IXlFormulaParameter.
using (IXlRow row = sheet.CreateRow()) {
    row.SkipCells(2);
    using (IXlCell cell = row.CreateCell()) {
        cell.Value = "Total:";
        cell.ApplyFormatting(totalRowFormatting);
    }
    using (IXlCell cell = row.CreateCell()) {
        // Set the formula to calculate the total amount plus 10 handling fee.
        // =SUM($D$2:$D$5)+10
        IXlFormulaParameter const10 = XlFunc.Param(10);
        IXlFormulaParameter sumAmountFunction = XlFunc.Sum(XlCellRange.FromLTRB(cell.ColumnIndex, 1, cell.ColumnIndex, row.RowIndex - 1).AsAbsolute());
        cell.SetFormula(XlOper.Add(sumAmountFunction, const10));
        cell.ApplyFormatting(totalRowFormatting);
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the FromLTRB(Int32, Int32, Int32, Int32) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also