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 datas of the area. | ||
function | sort(cells, startRow, startColumn, endRow, endColumn) | |
| Sorts the data of the area. | ||
| Property Getters/Setters Detail |
|---|
getKeys : DataSorterKeyCollection | |
function getKeys() | |
hasHeaders/setHasHeaders : boolean | |
function hasHeaders() / function setHasHeaders(value) | |
getKey1/setKey1 : Number | |
function getKey1() / function setKey1(value) | |
getOrder1/setOrder1 : Number | |
function getOrder1() / function setOrder1(value) | |
getKey2/setKey2 : Number | |
function getKey2() / function setKey2(value) | |
getOrder2/setOrder2 : Number | |
function getOrder2() / function setOrder2(value) | |
getKey3/setKey3 : Number | |
function getKey3() / function setKey3(value) | |
getOrder3/setOrder3 : Number | |
function getOrder3() / function setOrder3(value) | |
getSortLeftToRight/setSortLeftToRight : boolean | |
function getSortLeftToRight() / function setSortLeftToRight(value) | |
getCaseSensitive/setCaseSensitive : boolean | |
function getCaseSensitive() / function setCaseSensitive(value) | |
getSortAsNumber/setSortAsNumber : boolean | |
function getSortAsNumber() / function setSortAsNumber(value) | |
| Method Detail |
|---|
clear | |
function clear() | |
addKey | |
function addKey(key, order) | |
key: Number - The sorted column index(absolute position, column A is 0, B is 1, ...)order: Number - A addKey | |
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.addKey | |
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.addKey | |
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.sort | |
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.sort | |
function sort(cells, area) | |
cells: Cells - The cells contains the data area.area: CellArea - The area needed to sortsort | |
function sort() | |