int w = right - left + 1;
int h = bottom - top + 1;
//check merge range;
JSONObj jresult = new JSONObj();
List rd = new ArrayList();
jresult.setData("type","jump");
jresult.setData("dir","jump");
jresult.setData("left",left);
jresult.setData("top",top);
jresult.setData("width",w);
jresult.setData("height",h);
jresult.setData("data",rd);
// prepare header
JSONObj jheader;
List theaders = null;
List lheaders = null;
boolean filltheader = false;
if(!_hidecolhead){
theaders = new ArrayList();
jresult.setData("theader",theaders);
}
if(!_hiderowhead){
lheaders = new ArrayList();
jresult.setData("lheader",lheaders);
}
JSONObj jrow,jcell;
//append row
int re = top+h;
int ce = left+w;
for(int i=top;i<re;i++){
jrow = new JSONObj();
rd.add(jrow);
prepareRowData(jrow,sheet,i);
List cells = new ArrayList();
jrow.setData("cells",cells);
for(int j=left;j<ce;j++){
jcell = new JSONObj();
Cell cell = sheet.getCell(i,j);
cells.add(jcell);
prepareCellData(jcell,sheet,i,j);
if(!_hidecolhead && !filltheader){
jheader = new JSONObj();
prepareTopHeaderData(jheader,j);
theaders.add(jheader);
}
}
filltheader = true;
if(!_hiderowhead){
jheader = new JSONObj();
prepareLeftHeaderData(jheader,i);
lheaders.add(jheader);
}
}
_lastleft = left;
_lastright = right;
_lasttop = top;
_lastbottom = bottom;
//prepare top frozen cell
int fzr = _spreadsheet.getRowfreeze();
if(fzr>-1){
JSONObj topFrozen = new JSONObj();
jresult.setData("topfrozen",topFrozen);
List tfrd = new ArrayList();
topFrozen.setData("type","jump");
topFrozen.setData("dir","jump");
topFrozen.setData("left",left);
topFrozen.setData("top",0);
topFrozen.setData("width",w);
topFrozen.setData("height",fzr+1);
topFrozen.setData("data",tfrd);
ce = left+w;
for(int i=0;i<=fzr;i++){
jrow = new JSONObj();
tfrd.add(jrow);
prepareRowData(jrow,sheet,i);
List cells = new ArrayList();
jrow.setData("cells",cells);
for(int j=left;j<ce;j++){
jcell = new JSONObj(); //cell
Cell cell = sheet.getCell(i,j);
cells.add(jcell);
prepareCellData(jcell,sheet,i,j);
}
}
}
//prepare left frozen cell
int fzc = _spreadsheet.getColumnfreeze();
if(fzc>-1){
JSONObj leftFrozen = new JSONObj();
jresult.setData("leftfrozen",leftFrozen);
List lfrd = new ArrayList();
leftFrozen.setData("type","jump");
leftFrozen.setData("dir","jump");
leftFrozen.setData("left",0);
leftFrozen.setData("top",top);
leftFrozen.setData("width",fzc+1);
leftFrozen.setData("height",h);
leftFrozen.setData("data",lfrd);
re = top+h;
for(int i=top;i<re;i++){
jrow = new JSONObj();
lfrd.add(jrow);
prepareRowData(jrow,sheet,i);
List cells = new ArrayList();
jrow.setData("cells",cells);
for(int j=0;j<=fzc;j++){
jcell = new JSONObj(); //cell
Cell cell = sheet.getCell(i,j);
cells.add(jcell);
prepareCellData(jcell,sheet,i,j);
}
}