/// <summary> /// 计算输出区域 (以内容输出区域左上角为0,0开始计算、不考虑缩放、页眉页脚平移) /// 如果是合并单元格,包含整个合并区域 /// 必须经过平移、缩放放才有意义 /// </summary> /// <param name="bitmap"></param> /// <param name="reportData"></param> /// <param name="cell"></param> private static RectangleF CalCellDrawRect_UnScale(I3ReportDatas reportDatas, I3ReportCell cell, I3PrintArea area, I3ReportCell mergedCell) { //X、Y先求原单元格的 int row = mergedCell == null ? cell.Row : mergedCell.Row; int col = mergedCell == null ? cell.Col : mergedCell.Col; I3RowColType rowType = area.ReportData[row].Type; I3RowColType colType = area.ReportData.Cols[col].Type; //Width、Heigth求合并的 I3MergeRange range = cell.GetRange_Mode2(area.ReportData); RectangleF rect = new RectangleF(0F, 0F, 0F, 0F); #region Y IList <int> rows = null; switch (rowType) { case I3RowColType.页眉: rows = area.HeaderRows.Keys; break; case I3RowColType.页脚: rows = area.FooterRows.Keys; break; default: rows = area.DataRows.Keys; break; } foreach (int i in rows) { if (i < row) { rect.Y += area.ReportData[i].Height; } } #endregion #region Height for (int i = range.StartRow; i <= range.EndRow; i++) //高度为合并区域的高度的和 { rect.Height += area.ReportData[i].Height; } #endregion #region X IList <int> cols = null; switch (colType) { case I3RowColType.页眉: cols = area.HeaderCols.Keys; break; case I3RowColType.页脚: cols = area.FooterCols.Keys; break; default: cols = area.DataCols.Keys; break; } foreach (int i in cols) { if (i < col) { rect.X += area.ReportData.Cols[i].Width; } } #endregion #region Width for (int i = range.StartCol; i <= range.EndCol; i++) { rect.Width += area.ReportData.Cols[i].Width; } #endregion #region 画合并单元格的部分时,左移、上移 if (mergedCell != null) { for (int i = cell.Row; i < mergedCell.Row; i++) { rect.Y -= area.ReportData[i].Height; } for (int i = cell.Col; i < mergedCell.Col; i++) { rect.X -= area.ReportData.Cols[i].Width; } } #endregion return(rect); }
/// <summary> /// 计算剪切区域 /// 如果是合并单元格,不包含整个合并区域,只包含单元格本身 /// 必须经过平移、缩放放才有意义 /// </summary> /// <param name="reportData"></param> /// <param name="cell"></param> /// <param name="area"></param> /// <returns></returns> private static RectangleF CalCellClipRect_UnScale(I3ReportDatas reportDatas, I3ReportCell cell, I3PrintArea area) { int row = cell.Row; int col = cell.Col; I3RowColType rowType = area.ReportData[row].Type; I3RowColType colType = area.ReportData.Cols[col].Type; RectangleF rect = new RectangleF(0F, 0F, 0F, 0F); #region Y IList <int> rows = null; switch (rowType) { case I3RowColType.页眉: rows = area.HeaderRows.Keys; break; case I3RowColType.页脚: rows = area.FooterRows.Keys; break; default: rows = area.DataRows.Keys; break; } foreach (int i in rows) { if (i < row) { rect.Y += area.ReportData[i].Height; } } #endregion rect.Height = area.ReportData[cell.Row].Height; #region X IList <int> cols = null; switch (colType) { case I3RowColType.页眉: cols = area.HeaderCols.Keys; break; case I3RowColType.页脚: cols = area.FooterCols.Keys; break; default: cols = area.DataCols.Keys; break; } foreach (int i in cols) { if (i < col) { rect.X += area.ReportData.Cols[i].Width; } } #endregion rect.Width = area.ReportData.Cols[cell.Col].Width; return(rect); }