Article Details
Id:18807
Product:finPOWER Connect
Type:NEW
Version:3.04.03
Opened:10/06/2021
Closed:06/12/2021
Released:01/02/2022
Job: J026742

Excel Workbook functions; added Sort function to ISExcelWorksheet

A new Sort function has been added to ISExcelWorksheet. This allows a range of cells to be sorted.

The Sort function takes in a Range of Cells to sort and a list of Sort Levels to apply.

An example is shown below:

Dim ExcelWorkbook As ISExcelWorkbook
Dim i As Integer

ExcelWorkBook = finBL.CreateExcelWorkbook
With ExcelWorkBook
  ' Create Worksheet
  .Worksheets.Add("Sort Test")

  With .Worksheets(0)
    For i = 1 To 10 Step 1
      .Cell(1,i).SetInteger(i)
      .Cell(2,i).SetInteger(11-i)
      .Cell(3,i).SetInteger(finBL.Runtime.NumberUtilities.GetRandomInteger(0,100))
    Next

    .Cell(4, 1).SetString("Tim")
    .Cell(4, 2).SetString("Tom")
    .Cell(4, 3).SetString("Jennifer")
    .Cell(4, 4).SetString("Jake")
    .Cell(4, 5).SetString("Toby")
    .Cell(4, 6).SetString("Anna")
    .Cell(4, 7).SetString("Bob")
    .Cell(4, 8).SetString("Robert")
    .Cell(4, 9).SetString("Chloe")
    .Cell(4, 10).SetString("Jim")

    Main = .Sort(.CreateCellRange(), New List(Of ISExcelSortLevel) From {New ISExcelSortLevel(4)})
  End With
End With