/// <summary>
/// 读取合并单元格的值
/// </summary>
/// <param name="cell">查询的单元格</param>
/// <returns>返回有数值的单元格</returns>
private ICell MergedCell(ICell cell)
{
if (cell.IsMergedCell)//是否是合并单元格
{
for (int i = 0; i < cell.Sheet.NumMergedRegions; i++)//遍历所有的合并单元格
{
var cellRange = cell.Sheet.GetMergedRegion(i);
if (cell.ColumnIndex >= cellRange.FirstColumn && cell.ColumnIndex <= cellRange.LastColumn
&& cell.RowIndex >= cellRange.FirstRow && cell.RowIndex <= cellRange.LastRow)//判断查询的单元格是否在合并单元格内
{
return cell.Sheet.GetRow(cellRange.FirstRow).GetCell(cellRange.FirstColumn);
}
}
}
return cell;
}
05-24