/**
* 融合指定表格列
* @param table 融合的表格
* @param columnKey 融合参考列
* @param columnKeys 根据参考列需融合的列的集合
*/
public static void mergeColumns(KDTable table,String columnKey,String[] columnKeys)
{
int beginIndex = 0;
int endIndex = 0;
KDTMergeManager merGeManager = table.getMergeManager();
for(int i=1;i<table.getRowCount();i++)
{
Object objBegin = table.getCell(beginIndex, columnKey).getValue();
Object objCurr = table.getCell(i, columnKey).getValue();
if(i<table.getRowCount()-1)
{
if(objCurr!=null && objBegin!=null && objCurr.toString().equals(objBegin.toString()))
{
continue;
}
endIndex = i-1;
for(int j=0;j<columnKeys.length;j++)
{
merGeManager.mergeBlock(beginIndex, table.getColumnIndex(columnKeys[j]), endIndex, table.getColumnIndex(columnKeys[j]));
}
beginIndex = i;
}else
{
if(objCurr!=null && objBegin!=null && objCurr.toString().equals(objBegin.toString()))
{
endIndex = i;
}else
{
endIndex = i-1;
}
for(int j=0;j<columnKeys.length;j++)
{
merGeManager.mergeBlock(beginIndex, table.getColumnIndex(columnKeys[j]), endIndex, table.getColumnIndex(columnKeys[j]));
}
}
}
}
融合指定表格列
最新推荐文章于 2018-10-16 10:57:49 发布