//table:表格;reference:参考列;col:需要融合的列;
//例如:相同id的编码、名称进行融合:meregeTable(table,"id",new String[]{"number","name"})
public static void meregeTable(KDTable table,String reference,String[] col){
KDTMergeManager kmm = table.getMergeManager();
int[] indexs=new int[col.length];
for(int j=0,m=col.length;j<m;j++){
indexs[j]=table.getColumnIndex(col[j]);
}
int i=0,temp=-1;
Object begin=null;
Object cur=null;
for(int n=table.getRowCount();i<n;i++){
if(i==0){
begin=table.getCell(i,reference).getValue();
cur=table.getCell(i,reference).getValue();
temp=i;
continue;
}
cur=table.getCell(i,reference).getValue();
if(cur!=null&&cur.equals(begin)){
continue;
}
for(int j=0,m=col.length;j<m;j++){
kmm.mergeBlock(temp, indexs[j], i-1, indexs[j], KDTMergeManager.SPECIFY_MERGE);
}
begin=table.getCell(i,reference).getValue();
temp=i;
}
for(int j=0,m=col.length;j<m;j++){
kmm.mergeBlock(temp, indexs[j], i-1, indexs[j], KDTMergeManager.SPECIFY_MERGE);
}
}