I am trying to export a grid to excel in javascript. I have iterated through all rows and exported them correctly. I am having trouble implementing the hierachical nature in excel. Is there a way to group the rows through javascript for the excel sheet?? My code is below and the commented part is where I need to group the rows.
for(var i = 0; i< rowlength; i++)
{
row = rows.getRow(i);
if (!row.getHidden())
{
if (row.GroupByRow)
{
XlSheet.cells(y,1).value = row.MaskedValue;
var test = XlSheet.rows;
y++;
for(var j = 0; j < row.ChildRowsCount; j++)
{
x=1;
var childrow = row.getChildRow(j);
if (!childrow.getHidden())
{
var _band = childrow.Band;
var _childcolumns = _band.Columns;
var child_length = _childcolumns.length;
for (var k = 1; k < child_length; k++)
{
if (!(k == 4 || k == 8 || k == 9 || k == 10))
{
if (!childrow.getHidden())
{
cell = childrow.getCell(k);
the_value = cell.getValue();
XlSheet.cells(y,x).value = the_value;
x++;
}
}
}
}
y++;
}
// group rows under corresponding company, category
// something like ?? ---> XlSheet.GroupRows(XlSheet.rows(1), XlSheet.rows(x-1));
}
}
for(var i = 0; i< rowlength; i++)
{
row = rows.getRow(i);
if (!row.getHidden())
{
if (row.GroupByRow)
{
XlSheet.cells(y,1).value = row.MaskedValue;
var test = XlSheet.rows;
y++;
for(var j = 0; j < row.ChildRowsCount; j++)
{
x=1;
var childrow = row.getChildRow(j);
if (!childrow.getHidden())
{
var _band = childrow.Band;
var _childcolumns = _band.Columns;
var child_length = _childcolumns.length;
for (var k = 1; k < child_length; k++)
{
if (!(k == 4 || k == 8 || k == 9 || k == 10))
{
if (!childrow.getHidden())
{
cell = childrow.getCell(k);
the_value = cell.getValue();
XlSheet.cells(y,x).value = the_value;
x++;
}
}
}
}
y++;
}
// group rows under corresponding company, category
// something like ?? ---> XlSheet.GroupRows(XlSheet.rows(1), XlSheet.rows(x-1));
}
}