Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
It is possible to group rows or columns by calling the groupRows and groupColumns methods of the Cells collection. Both methods take the following parameters:
PHP Code
public static function group_rows_columns($dataDir)
{
# Instantiating a Workbook object by excel file path
$workbook = new Workbook($dataDir . 'Book1.xls');
# Accessing the first worksheet in the Excel file
$worksheet = $workbook->getWorksheets()->get(0);
$cells = $worksheet->getCells();;
# Grouping first six rows (from 0 to 5) and making them hidden by passing true
$cells->groupRows(0,5,true);
# Grouping first three columns (from 0 to 2) and making them hidden by passing true
$cells->groupColumns(0,2,true);
# Saving the modified Excel file in default (that is Excel 2003) format
$workbook->save($dataDir . "Group Rows And Columns.xls");
print "Group Rows And Columns Successfully." . PHP_EOL;
}
Ungroup grouped rows or columns by calling the Cells collection’s UngroupRows and UngroupColumns methods. Both methods take the same parameters:
PHP Code
public static function ungroup_rows_columns($dataDir)
{
# Instantiating a Workbook object by excel file path
$workbook = new Workbook($dataDir . 'Group Rows And Columns.xls');
# Accessing the first worksheet in the Excel file
$worksheet = $workbook->getWorksheets()->get(0);
$cells = $worksheet->getCells();;
# Ungrouping first six rows (from 0 to 5)
$cells->ungroupRows(0,5);
# Ungrouping first three columns (from 0 to 2)
$cells->ungroupColumns(0,2);
# Saving the modified Excel file in default (that is Excel 2003) format
$workbook->save($dataDir . "Ungroup Rows And Columns.xls");
print "Ungroup Rows And Columns Successfully." . PHP_EOL;
}
Download Group & Ungroup Rows & Columns (Aspose.Cells) from any of the below mentioned social coding sites:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.