EasyXLS™ library allows you to group data on rows and columns, so that the user can show/hide data. The data is organized in levels. The outline levels are determined automatically, based on the group data range.
// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument workbook = new ExcelDocument(2);
// Add data to Excel file
...
// Group data on a range of cells, level 1
ExcelDataGroup xlsFirstDataGroup =
new ExcelDataGroup("A1:E26", DataGroup.GROUP_BY_ROWS, false);
xlsFirstDataGroup.setAutoFormat(
new ExcelAutoFormat(EasyXLS.Constants.Styles.AUTOFORMAT_EASYXLS1));
((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_addDataGroup(xlsFirstDataGroup);
// Group data on a range inside the first range, level 2
ExcelDataGroup xlsSecondDataGroup =
new ExcelDataGroup("A2:E10", DataGroup.GROUP_BY_ROWS, false);
xlsSecondDataGroup.setAutoFormat(
new ExcelAutoFormat(EasyXLS.Constants.Styles.AUTOFORMAT_EASYXLS2));
((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_addDataGroup(xlsSecondDataGroup);
...
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel grouping and outline levels.xlsx");
' Create an instance of the class that exports Excel files, having two sheetsDim workbook As New ExcelDocument(2)
' Add data to Excel file
...
' Group data on a range of cells, level 1Dim xlsFirstDataGroup As New ExcelDataGroup("A1:E26", DataGroup.GROUP_BY_ROWS, False)
xlsFirstDataGroup.setAutoFormat( _
New ExcelAutoFormat(EasyXLS.Constants.Styles.AUTOFORMAT_EASYXLS1))
xlsFirstTab.easy_addDataGroup(xlsFirstDataGroup)
' Group data on a range inside the first range, level 2Dim xlsSecondDataGroup As New ExcelDataGroup("A2:E10", _
DataGroup.GROUP_BY_ROWS, False)
xlsSecondDataGroup.setAutoFormat( _
New ExcelAutoFormat(EasyXLS.Constants.Styles.AUTOFORMAT_EASYXLS2))
xlsFirstTab.easy_addDataGroup(xlsSecondDataGroup)
...
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\Excel grouping and outline levels.xlsx")
C++// Create an instance of the class that exports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Add data to Excel file
...
// Group data on a range of cells, level 1
EasyXLS::IExcelDataGroupPtr xlsFirstDataGroup ;
CoCreateInstance(__uuidof(EasyXLS::ExcelDataGroup), NULL, CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDataGroupPtr), (void**) &xlsFirstDataGroup);
xlsFirstDataGroup->setRange_2("A1:E26");
xlsFirstDataGroup->setGroupType(DATAGROUP_GROUP_BY_ROWS);
xlsFirstDataGroup->setCollapsed(false);
// Format range of cells for first data group
EasyXLS::IExcelAutoFormatPtr xlsAutoFormat;
CoCreateInstance(__uuidof(EasyXLS::ExcelAutoFormat), NULL, CLSCTX_ALL,
__uuidof(EasyXLS::IExcelAutoFormat), (void**) &xlsAutoFormat);
xlsAutoFormat->InitAs(AUTOFORMAT_EASYXLS1);
xlsFirstDataGroup->setAutoFormat(xlsAutoFormat);
xlsFirstTab->easy_addDataGroup(xlsFirstDataGroup);
// Group data on a range inside the first range, level 2
EasyXLS::IExcelDataGroupPtr xlsSecondDataGroup;
CoCreateInstance(__uuidof(EasyXLS::ExcelDataGroup), NULL, CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDataGroupPtr), (void**) &xlsSecondDataGroup);
xlsSecondDataGroup->setRange_2("A2:E10");
xlsSecondDataGroup->setGroupType(DATAGROUP_GROUP_BY_ROWS);
xlsSecondDataGroup->setCollapsed(false);
// Format range of cells for second data group
EasyXLS::IExcelAutoFormatPtr xlsAutoFormat2;
CoCreateInstance(__uuidof(EasyXLS::ExcelAutoFormat), NULL, CLSCTX_ALL,
__uuidof(EasyXLS::IExcelAutoFormat), (void**) &xlsAutoFormat2);
xlsAutoFormat2->InitAs(AUTOFORMAT_EASYXLS2);
xlsSecondDataGroup->setAutoFormat(xlsAutoFormat2);
xlsFirstTab->easy_addDataGroup(xlsSecondDataGroup);
...
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel grouping and outline levels.xlsx");
Click here to see Continuous Code ListingC++.NET// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument ^workbook = gcnew ExcelDocument(2);
// Add data to Excel file
...
// Group data on a range of cells, level 1
ExcelDataGroup ^xlsFirstDataGroup =
gcnew ExcelDataGroup("A1:E26", DataGroup::GROUP_BY_ROWS, false);
xlsFirstDataGroup->setAutoFormat(gcnew ExcelAutoFormat(Styles::AUTOFORMAT_EASYXLS1));
xlsFirstTab->easy_addDataGroup(xlsFirstDataGroup);
// Group data on a range inside the first range, level 2
ExcelDataGroup ^xlsSecondDataGroup =
gcnew ExcelDataGroup("A2:E10", DataGroup::GROUP_BY_ROWS, false);
xlsSecondDataGroup->setAutoFormat(gcnew ExcelAutoFormat(Styles::AUTOFORMAT_EASYXLS2));
xlsFirstTab->easy_addDataGroup(xlsSecondDataGroup);
...
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel grouping and outline levels.xlsx");
Click here to see Continuous Code Listing
// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument workbook = new ExcelDocument(2);
// Add data to Excel file
...
// Group data on a range of cells, level 1
ExcelDataGroup xlsFirstDataGroup =
new ExcelDataGroup("A1:E26", DataGroup.GROUP_BY_ROWS, false);
xlsFirstDataGroup.setAutoFormat(
new ExcelAutoFormat(EasyXLS.Constants.Styles.AUTOFORMAT_EASYXLS1));
((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_addDataGroup(xlsFirstDataGroup);
// Group data on a range inside the first range, level 2
ExcelDataGroup xlsSecondDataGroup =
new ExcelDataGroup("A2:E10", DataGroup.GROUP_BY_ROWS, false);
xlsSecondDataGroup.setAutoFormat(
new ExcelAutoFormat(EasyXLS.Constants.Styles.AUTOFORMAT_EASYXLS2));
((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_addDataGroup(xlsSecondDataGroup);
...
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel grouping and outline levels.xlsx");
.NET:// Create an instance of the class that exports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Add data to Excel file
...
// Group data on a range of cells, level 1
$xlsFirstDataGroup = new COM("EasyXLS.ExcelDataGroup");
$xlsFirstDataGroup->setRange_2 ("A1:E26");
$xlsFirstDataGroup->setGroupType ($DATAGROUP_GROUP_BY_ROWS);
$xlsFirstDataGroup->setCollapsed (False);
// Format range of cells for first data group
$xlsAutoFormat = new COM("EasyXLS.ExcelAutoFormat");
$xlsAutoFormat->InitAs($AUTOFORMAT_EASYXLS1);
$xlsFirstDataGroup->setAutoFormat($xlsAutoFormat);
$workbook->easy_getSheetAt(0)->easy_addDataGroup($xlsFirstDataGroup);
// Group data on a range inside the first range, level 2
$xlsSecondDataGroup = new COM("EasyXLS.ExcelDataGroup");
$xlsSecondDataGroup->setRange_2("A2:E10");
$xlsSecondDataGroup->setGroupType($DATAGROUP_GROUP_BY_ROWS);
$xlsSecondDataGroup->setCollapsed(False);
// Format range of cells for second data group
$xlsAutoFormat2 = new COM("EasyXLS.ExcelAutoFormat");
$xlsAutoFormat2->InitAs($AUTOFORMAT_EASYXLS2);
$xlsSecondDataGroup->setAutoFormat($xlsAutoFormat2);
$workbook->easy_getSheetAt(0)->easy_addDataGroup($xlsSecondDataGroup);
...
// Export Excel file
$workbook->easy_WriteXLSXFile("C:\Samples\Excel grouping and outline levels.xlsx");
Click here to see Continuous Code ListingJava:// Create an instance of the class that exports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Add data to Excel file
...
// Group rows and format A1:E26 cell range
$xlsFirstDataGroup = new java("EasyXLS.ExcelDataGroup");
$xlsFirstDataGroup->setRange("A1:E26");
$xlsFirstDataGroup->setGroupType ($DATAGROUP_GROUP_BY_ROWS);
$xlsFirstDataGroup->setCollapsed (False);
$xlsAutoFormat = new java("EasyXLS.ExcelAutoFormat");
$xlsAutoFormat->InitAs($AUTOFORMAT_EASYXLS1);
$xlsFirstDataGroup->setAutoFormat($xlsAutoFormat);
$workbook->easy_getSheetAt(0)->easy_addDataGroup($xlsFirstDataGroup);
// Group rows and format A2:E10 cell range, outline level two, inside previous group
$xlsSecondDataGroup = new java("EasyXLS.ExcelDataGroup");
$xlsSecondDataGroup->setRange("A2:E10");
$xlsSecondDataGroup->setGroupType($DATAGROUP_GROUP_BY_ROWS);
$xlsSecondDataGroup->setCollapsed(False);
$xlsAutoFormat2 = new java("EasyXLS.ExcelAutoFormat");
$xlsAutoFormat2->InitAs($AUTOFORMAT_EASYXLS2);
$xlsSecondDataGroup->setAutoFormat($xlsAutoFormat2);
$workbook->easy_getSheetAt(0)->easy_addDataGroup($xlsSecondDataGroup);
// Export Excel file
$workbook->easy_WriteXLSXFile("C:\Samples\Excel grouping and outline levels.xlsx");
Click here to see Continuous Code Listing
' Create an instance of the class that exports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Add data to Excel file
...
' Group data on a range of cells, level 1Set xlsFirstDataGroup = Server.CreateObject("EasyXLS.ExcelDataGroup")
xlsFirstDataGroup.setRange_2 ("A1:E26")
xlsFirstDataGroup.setGroupType (DATAGROUP_GROUP_BY_ROWS)
xlsFirstDataGroup.setCollapsed (False)
' Format range of cells for first data groupDim xlsAutoFormat
Set xlsAutoFormat = Server.CreateObject("EasyXLS.ExcelAutoFormat")
xlsAutoFormat.InitAs (AUTOFORMAT_EASYXLS1)
xlsFirstDataGroup.setAutoFormat (xlsAutoFormat)
workbook.easy_getSheetAt(0).easy_addDataGroup (xlsFirstDataGroup)
' Group data on a range inside the first range, level 2Set xlsSecondDataGroup = Server.CreateObject("EasyXLS.ExcelDataGroup")
xlsSecondDataGroup.setRange_2 ("A2:E10")
xlsSecondDataGroup.setGroupType (DATAGROUP_GROUP_BY_ROWS)
xlsSecondDataGroup.setCollapsed (False)
' Format range of cells for second data groupDim xlsAutoFormat2
Set xlsAutoFormat2 = Server.CreateObject("EasyXLS.ExcelAutoFormat")
xlsAutoFormat2.InitAs (AUTOFORMAT_EASYXLS2)
xlsSecondDataGroup.setAutoFormat (xlsAutoFormat2)
workbook.easy_getSheetAt(0).easy_addDataGroup (xlsSecondDataGroup)
...
' Export Excel file
workbook.easy_WriteXLSXFile ("C:\Samples\Excel grouping and outline levels.xlsx")
' Create an instance of the class that exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Add data to Excel file
...
' Group data on a range of cells, level 1Set xlsFirstDataGroup = CreateObject("EasyXLS.ExcelDataGroup")
xlsFirstDataGroup.setRange_2 ("A1:E26")
xlsFirstDataGroup.setGroupType (DataGroup.DATAGROUP_GROUP_BY_ROWS)
xlsFirstDataGroup.setCollapsed (False)
' Format range of cells for first data groupDim xlsAutoFormat
Set xlsAutoFormat = CreateObject("EasyXLS.ExcelAutoFormat")
xlsAutoFormat.InitAs (Styles.AUTOFORMAT_EASYXLS1)
xlsFirstDataGroup.setAutoFormat (xlsAutoFormat)
workbook.easy_getSheetAt(0).easy_addDataGroup (xlsFirstDataGroup)
' Group data on a range inside the first range, level 2Set xlsSecondDataGroup = CreateObject("EasyXLS.ExcelDataGroup")
xlsSecondDataGroup.setRange_2 ("A2:E10")
xlsSecondDataGroup.setGroupType (DataGroup.DATAGROUP_GROUP_BY_ROWS)
xlsSecondDataGroup.setCollapsed (False)
' Format range of cells for second data groupDim xlsAutoFormat2
Set xlsAutoFormat2 = CreateObject("EasyXLS.ExcelAutoFormat")
xlsAutoFormat2.InitAs (Styles.AUTOFORMAT_EASYXLS2)
xlsSecondDataGroup.setAutoFormat (xlsAutoFormat2)
workbook.easy_getSheetAt(0).easy_addDataGroup (xlsSecondDataGroup)
...
' Export Excel file
workbook.easy_WriteXLSXFile ("C:\Samples\Excel grouping and outline levels.xlsx")
' Create an instance of the class that exports Excel filesset workbook = CreateObject("EasyXLS.ExcelDocument")
' Add data to Excel file
...
' Group data on a range of cells, level 1Set xlsFirstDataGroup = CreateObject("EasyXLS.ExcelDataGroup")
xlsFirstDataGroup.setRange_2 ("A1:E26")
xlsFirstDataGroup.setGroupType (DATAGROUP_GROUP_BY_ROWS)
xlsFirstDataGroup.setCollapsed (False)
' Format range of cells for first data groupDim xlsAutoFormat
Set xlsAutoFormat = CreateObject("EasyXLS.ExcelAutoFormat")
xlsAutoFormat.InitAs (AUTOFORMAT_EASYXLS1)
xlsFirstDataGroup.setAutoFormat (xlsAutoFormat)
workbook.easy_getSheetAt(0).easy_addDataGroup (xlsFirstDataGroup)
' Group data on a range inside the first range, level 2Set xlsSecondDataGroup = CreateObject("EasyXLS.ExcelDataGroup")
xlsSecondDataGroup.setRange_2 ("A2:E10")
xlsSecondDataGroup.setGroupType (DATAGROUP_GROUP_BY_ROWS)
xlsSecondDataGroup.setCollapsed (False)
' Format range of cells for second data groupDim xlsAutoFormat2
Set xlsAutoFormat2 = CreateObject("EasyXLS.ExcelAutoFormat")
xlsAutoFormat2.InitAs (AUTOFORMAT_EASYXLS2)
xlsSecondDataGroup.setAutoFormat (xlsAutoFormat2)
workbook.easy_getSheetAt(0).easy_addDataGroup (xlsSecondDataGroup)
...
' Export Excel file
workbook.easy_WriteXLSXFile ("C:\Samples\Excel grouping and outline levels.xlsx")
<!-- Create an instance of the class that exports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Add data to Excel file -->
...
<!-- Group data on a range of cells, level 1 --><cfobject type="java"class="EasyXLS.ExcelDataGroup"name="xlsFirstDataGroup"action="CREATE"><cfset xlsFirstDataGroup.setRange("A1:E26")><cfset xlsFirstDataGroup.setGroupType(DataGroup.GROUP_BY_ROWS)><cfset xlsFirstDataGroup.setCollapsed(false)><!-- Format range of cells for first data group --><cfobject type="java"class="EasyXLS.ExcelAutoFormat"name="xlsAutoFormat"action="CREATE"><cfset xlsAutoFormat.InitAs(Styles.AUTOFORMAT_EASYXLS1)><cfset xlsFirstDataGroup.setAutoFormat(xlsAutoFormat)><cfset workbook.easy_getSheetAt(0).easy_addDataGroup(xlsFirstDataGroup)><!-- Group data on a range inside the first range, level 2 --><cfobject type="java"class="EasyXLS.ExcelDataGroup"name="xlsSecondDataGroup"action="CREATE"><cfset xlsSecondDataGroup.setRange("A1:E26")><cfset xlsSecondDataGroup.setGroupType(DataGroup.GROUP_BY_ROWS)><cfset xlsSecondDataGroup.setCollapsed(false)><!-- Format range of cells for second data group --><cfobject type="java"class="EasyXLS.ExcelAutoFormat"name="xlsAutoFormat2"action="CREATE"><cfset xlsAutoFormat2.InitAs(Styles.AUTOFORMAT_EASYXLS2)><cfset xlsSecondDataGroup.setAutoFormat(xlsAutoFormat2)><cfset workbook.easy_getSheetAt(0).easy_addDataGroup(xlsSecondDataGroup)>
...
<!-- Export Excel file --><cfset ret = workbook.easy_WriteXLSXFile(
"C:\Samples\Excel grouping and outline levels.xlsx")>
.NET:# Create an instance of the class that exports Excel files having two sheets
workbook = ExcelDocument(2)
# Add data to Excel file
...
# Group data on a range of cells, level 1
xlsFirstDataGroup = ExcelDataGroup("A1:E26", DataGroup.GROUP_BY_ROWS, False)
xlsFirstDataGroup.setAutoFormat(ExcelAutoFormat(Styles.AUTOFORMAT_EASYXLS1))
workbook.easy_getSheetAt(0).easy_addDataGroup(xlsFirstDataGroup)
# Group data on a range inside the first range, level 2
xlsSecondDataGroup = ExcelDataGroup("A2:E10", DataGroup.GROUP_BY_ROWS, False)
xlsSecondDataGroup.setAutoFormat(ExcelAutoFormat(Styles.AUTOFORMAT_EASYXLS2))
workbook.easy_getSheetAt(0).easy_addDataGroup(xlsSecondDataGroup)
...
# Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel grouping and outline levels.xlsx")
Click here to see Continuous Code ListingJava:# Create an instance of the class that exports Excel files having two sheets
workbook = gateway.jvm.ExcelDocument(2)
# Add data to Excel file
...
# Group data on a range of cells, level 1
xlsFirstDataGroup = gateway.jvm.ExcelDataGroup("A1:E26", gateway.jvm.DataGroup.GROUP_BY_ROWS, False)
xlsFirstDataGroup.setAutoFormat(gateway.jvm.ExcelAutoFormat(gateway.jvm.Styles.AUTOFORMAT_EASYXLS1))
workbook.easy_getSheetAt(0).easy_addDataGroup(xlsFirstDataGroup)
# Group data on a range inside the first range, level 2
xlsSecondDataGroup = gateway.jvm.ExcelDataGroup("A2:E10", gateway.jvm.DataGroup.GROUP_BY_ROWS, False)
xlsSecondDataGroup.setAutoFormat(gateway.jvm.ExcelAutoFormat(gateway.jvm.Styles.AUTOFORMAT_EASYXLS2))
workbook.easy_getSheetAt(0).easy_addDataGroup(xlsSecondDataGroup)
...
# Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel grouping and outline levels.xlsx")
Click here to see Continuous Code Listing
The screen shot below represents an Excel report that includes a data group that has two outline levels of details for its data.