業務需要
解決方案
/// <summary>表格控件相關操作類
/// </summary>
public static class aspTable
{
/// <summary>合並行
/// </summary>
/// <remarks>版權信息
/// <param name="tbl">Table</param>
/// <param name="startRow">起始行</param>
/// <param name="endRow">結束行</param>
/// <param name="colIndex">要合並的列索引</param>
public static void SetRowSpan(Table tbl
{
int countRowSpan =
int spanRow = startRow;
string spanText = tbl
for (int rowIndex = startRow; rowIndex <= endRow; rowIndex++)
{
string currentText = tbl
//內容是否相同
if (currentText == spanText)
{
countRowSpan++;
//移除被合並的單元格
if (rowIndex != spanRow)
{
tbl
}
}
else
{
//合並
tbl
//從此行再向下比較(重置)
countRowSpan =
spanRow = rowIndex
spanText = currentText;
}
}
//合並最後一項
tbl
}
/// <summary>合並行
/// </summary>
/// <remarks><SPAN style="FONT
/// <param name="tbl">Table</param>
/// <param name="startRow">起始行</param>
/// <param name="endRow">結束行</param>
/// <param name="colIndex">要合並的列索引</param>
public static void SetRowSpans(Table tbl
{
ArrayList al = new ArrayList(colIndexs);
al
for (int i = al
{
SetRowSpan(tbl
}
}
}
需要注意的幾點
From:http://tw.wingwit.com/Article/program/net/201311/14044.html