private void SynBandCellData(PageInfo info, DataRow row, DataRow newRow, List <int> column) { CellStruct cellStruct = null; CellStruct tempStruct = null; int index = 0; foreach (int columnName in column) { cellStruct = row[columnName.ToString()] as CellStruct; if (cellStruct is MacrsCellStruct) { cellStruct = (cellStruct as MacrsCellStruct).ReplaceMacrs(info.PageMacrs); } if (!CellStruct.IsNullOrEmpty(cellStruct)) { if (cellStruct.ExcelInfo.ColMerge > column.Count - index) { cellStruct = cellStruct.Clone(); cellStruct.ExcelInfo.ColMerge = column.Count - index; } } if (index == 0 && CellStruct.IsNullOrEmpty(cellStruct)) { //查询该CellStruct之前是否有列合并Cell for (int i = columnName - 1; i > 0; i--) { tempStruct = row[i.ToString()] as CellStruct; if (!CellStruct.IsNullOrEmpty(tempStruct)) { if (tempStruct.ExcelInfo.ColMerge > columnName - i) { cellStruct = tempStruct.Clone(); cellStruct.ExcelInfo.ColMerge -= columnName - i; if (cellStruct.ExcelInfo.ColMerge > column.Count) { cellStruct.ExcelInfo.ColMerge = column.Count; } } break; } } } if (cellStruct is FunCellStruct) { string funResult = info.FunResults[cellStruct.Context]; cellStruct = cellStruct.Clone(); cellStruct.Context = funResult; } newRow[columnName.ToString()] = cellStruct; index++; } }
private void SynCellRowMergeUpCell(int rowIndex, int endIndex, DataRow dataRow, DataRow newRow, List <int> list) { CellStruct cellStruct = null; foreach (int colName in list) { cellStruct = dataRow[colName.ToString()] as CellStruct; if (CellStruct.IsNullOrEmpty(cellStruct)) { CellStruct tempCell = null; //向上找 for (int i = rowIndex - 1; i >= 0; i--) { tempCell = bodyData.Rows[i][colName.ToString()] as CellStruct; if (!CellStruct.IsNullOrEmpty(tempCell)) { if (tempCell.ExcelInfo.RowMerge > rowIndex - i) { int tempMerge = tempCell.ExcelInfo.RowMerge - (rowIndex - i); if (tempMerge > endIndex - rowIndex) { tempMerge = endIndex - rowIndex; } cellStruct = tempCell.Clone(); cellStruct.ExcelInfo.RowMerge = tempMerge; break; } } } } newRow[colName.ToString()] = cellStruct; } }
private void SynCellRowMergeDownCell(int rowIndex, int endIndex, DataRow dataRow, DataRow newRow, List <int> list) { CellStruct cellStruct = null; foreach (int columnName in list) { cellStruct = dataRow[columnName.ToString()] as CellStruct; if (cellStruct.ExcelInfo.RowMerge > endIndex - rowIndex) { cellStruct = cellStruct.Clone(); cellStruct.ExcelInfo.RowMerge = endIndex - rowIndex; } newRow[columnName.ToString()] = cellStruct; } }
private void SynTextCellData(PageInfo info, DataRow row, DataRow newRow, List <int> column) { CellStruct cellStruct = null; int index = 0; foreach (int columnName in column) { cellStruct = row[columnName.ToString()] as CellStruct; if (!CellStruct.IsNullOrEmpty(cellStruct) && cellStruct.ExcelInfo.ColMerge > column.Count - index) { cellStruct = cellStruct.Clone(); cellStruct.ExcelInfo.ColMerge = column.Count - index; } if (cellStruct is MacrsCellStruct) { cellStruct = (cellStruct as MacrsCellStruct).ReplaceMacrs(info.PageMacrs); } newRow[columnName.ToString()] = cellStruct; index++; } }