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:
Ruby Code
def group_rows_columns()
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
# Instantiating a Workbook object by an Excel file path
workbook = Rjb::import('com.aspose.cells.Workbook').new(data_dir + 'Book1.xls')
# Accessing the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
cells = worksheet.getCells()
# Grouping the first six rows (from 0 to 5) and making them hidden by passing true
cells.groupRows(0, 5, true)
# Grouping the 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 the default (Excel 2003) format
workbook.save(data_dir + "Group Rows And Columns.xls")
puts "Rows and columns grouped successfully."
endUngroup grouped rows or columns by calling the Cells collection’s UngroupRows and UngroupColumns methods. Both methods take the same parameters:
Ruby Code
def ungroup_rows_columns()
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
# Instantiating a Workbook object by an Excel file path
workbook = Rjb::import('com.aspose.cells.Workbook').new(data_dir + 'Group Rows And Columns.xls')
# Accessing the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
cells = worksheet.getCells()
# Ungrouping the first six rows (from 0 to 5)
cells.ungroupRows(0, 5)
# Ungrouping the first three columns (from 0 to 2)
cells.ungroupColumns(0, 2)
# Saving the modified Excel file in the default (Excel 2003) format
workbook.save(data_dir + "Ungroup Rows And Columns.xls")
puts "Rows and columns ungrouped successfully."
endDownload 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.