Example:
//Instantiate a new Workbook object. //Instantiate a new Workbook object $workbook = new cells\Workbook("Book1.xls"); //Get the workbook datasorter object $sorter = $workbook->getDataSorter(); //Set the first order for datasorter object $sorter->setOrder1(cells\SortOrder::DESCENDING); //Define the first key $sorter->setKey1(0); //Set the second order for datasorter object $sorter->setOrder2(cells\SortOrder::ASCENDING); //Define the second key $sorter->setKey2(1); //Create a cells area (range) $ca = new cells\CellArea(); //Specify the start row index $ca->StartRow = 0; //Specify the start column index $ca->StartColumn = 0; //Specify the last row index $ca->EndRow = 13; //Specify the last column index $ca->EndColumn = 1; //Sort data in the specified data range (A1:B14) $sorter->sort($workbook->getWorksheets()->get(0)->getCells(), $ca);
Property Getters/Setters Summary | ||
---|---|---|
function | getCaseSensitive() | |
function | setCaseSensitive(value) | |
Gets and sets whether case sensitive when comparing string. | ||
function | hasHeaders() | |
function | setHasHeaders(value) | |
Represents whether the range has headers. | ||
function | getKey1() | |
function | setKey1(value) | |
Represents first sorted column index(absolute position, column A is 0, B is 1, ...). | ||
function | getKey2() | |
function | setKey2(value) | |
Represents second sorted column index(absolute position, column A is 0, B is 1, ...). | ||
function | getKey3() | |
function | setKey3(value) | |
Represents third sorted column index(absolute position, column A is 0, B is 1, ...). | ||
function | getKeys() | |
Gets the key list of data sorter.
|
||
function | getOrder1() | |
function | setOrder1(value) | |
Represents sort order of the first key. The value of the property is SortOrder integer constant. | ||
function | getOrder2() | |
function | setOrder2(value) | |
Represents sort order of the second key. The value of the property is SortOrder integer constant. | ||
function | getOrder3() | |
function | setOrder3(value) | |
Represents sort order of the third key. The value of the property is SortOrder integer constant. | ||
function | getSortAsNumber() | |
function | setSortAsNumber(value) | |
Indicates whether sorting anything that looks like a number. | ||
function | getSortLeftToRight() | |
function | setSortLeftToRight(value) | |
True means that sorting orientation is from left to right. False means that sorting orientation is from top to bottom. The default value is false. |
Method Summary | ||
---|---|---|
function | addKey(key, order) | |
Adds sorted column index and sort order.
|
||
function | addKey(key, type, order, customList) | |
Adds sorted column index and sort order with custom sort list.
|
||
function | addKey(key, order, customList) | |
Adds sorted column index and sort order with custom sort list.
|
||
function | addKey(key, order, customList) | |
Adds sorted column index and sort order with custom sort list.
|
||
function | clear() | |
Clear all settings.
|
||
function | sort() | |
Sort the data in the range.
|
||
function | sort(cells, area) | |
Sort the data of the area.
|
||
function | sort(cells, startRow, startColumn, endRow, endColumn) | |
Sorts the data of the area.
|
function getKeys()
function hasHeaders() / function setHasHeaders(value)
function getKey1() / function setKey1(value)
function getOrder1() / function setOrder1(value)
function getKey2() / function setKey2(value)
function getOrder2() / function setOrder2(value)
function getKey3() / function setKey3(value)
function getOrder3() / function setOrder3(value)
function getSortLeftToRight() / function setSortLeftToRight(value)
function getCaseSensitive() / function setCaseSensitive(value)
function getSortAsNumber() / function setSortAsNumber(value)
function clear()
function addKey(key, order)
key: Number
- The sorted column index(absolute position, column A is 0, B is 1, ...)order: Number
- A function addKey(key, order, customList)
key: Number
- The sorted column index(absolute position, column A is 0, B is 1, ...)order: Number
- A customList: String
- The custom sort list.function addKey(key, type, order, customList)
key: Number
- The sorted column index(absolute position, column A is 0, B is 1, ...)type: Number
- A order: Number
- A customList: Object
- The custom sort list.function addKey(key, order, customList)
key: Number
- The sorted column index(absolute position, column A is 0, B is 1, ...)order: Number
- A customList: String[]
- The custom sort list.function sort(cells, startRow, startColumn, endRow, endColumn)
cells: Cells
- The cells contains the data area.startRow: Number
- The start row of the area.startColumn: Number
- The start column of the area.endRow: Number
- The end row of the area.endColumn: Number
- The end column of the area.function sort(cells, area)
cells: Cells
- The cells contains the data area.area: CellArea
- The area needed to sortfunction sort()