Exemple #1
0
        /// <summary>
        /// 按纸张尺寸分页
        /// </summary>
        /// <param name="reportData"></param>
        private static I3PrintAreas CalPrintAreas(I3ReportData reportData)
        {
            I3PrintAreas rowPringAreas = CalPrintAreasByRows(reportData);
            I3PrintAreas printAreas    = CalPrintAreasByCols(reportData, rowPringAreas);

            return(printAreas);
        }
Exemple #2
0
        private static I3PrintAreas CalPrintAreasByCols(I3ReportData reportData, I3PrintAreas rowAreas)
        {
            I3PageSetting setting    = reportData.PageSetting;
            float         paperWidth = setting.PaperContentRect.Width;

            I3PrintAreas printAreas = new I3PrintAreas();

            foreach (int row in rowAreas.Dic.Keys)
            {
                I3PrintArea rowArea    = rowAreas.Dic[row];
                float       totalWidth = rowArea.Width;
                List <int>  cols       = new List <int>();
                for (int j = 0; j < reportData.ColCount; j++)
                {
                    if (reportData.Cols[j].Type != I3RowColType.数据 || reportData.Cols[j].Type == I3RowColType.None)
                    {
                        continue;
                    }
                    int colWidth = reportData.Cols[j].Width;

                    #region 在此列前分页
                    //列后分页,条件:已有列被添加,前面一列的列后分页属性=true,已有列的总宽度>0
                    bool breakBeforeThisCol = cols.Count > 0 && reportData.Cols[cols[cols.Count - 1]].PageBreak && totalWidth > rowArea.Width;
                    //尺寸超过
                    breakBeforeThisCol = breakBeforeThisCol || (setting.ColsPagerStyle == PagerStyle.纸张尺寸分页 && totalWidth + colWidth > paperWidth);
                    //列数超过
                    breakBeforeThisCol = breakBeforeThisCol || (setting.ColsPagerStyle == PagerStyle.数据行列数分页 && cols.Count >= setting.ColsPerPage);

                    if (breakBeforeThisCol)
                    {
                        I3PrintArea area = rowArea.Clone().AddCols(cols);
                        area.Width = totalWidth;
                        printAreas.Add(printAreas.Dic.Count, area);
                        totalWidth = rowArea.Width + colWidth;
                        cols.Clear();
                        cols.Add(j);
                        continue;
                    }
                    #endregion

                    //不分页
                    totalWidth += colWidth;
                    cols.Add(j);
                }

                //最后有些列未能分页
                if (cols.Count > 0)
                {
                    I3PrintArea area = rowArea.Clone().AddCols(cols);
                    area.Height = totalWidth;
                    printAreas.Add(printAreas.Dic.Count, area);
                }
            }
            return(printAreas);
        }
Exemple #3
0
        private static I3PrintAreas CalPrintAreasByRows(I3ReportData reportData)
        {
            I3PageSetting setting     = reportData.PageSetting;
            float         paperHeight = setting.PaperContentRect.Height;
            I3PrintArea   defaultArea = GetDefaultRowPrintArea(reportData);

            //先按行划分
            I3PrintAreas rowPrintAreas = new I3PrintAreas();
            float        totalHeight   = defaultArea.Height;
            List <int>   rows          = new List <int>();

            for (int i = 0; i < reportData.RowCount; i++)
            {
                if (reportData[i].Type != I3RowColType.数据 || reportData[i].Type == I3RowColType.None)
                {
                    continue;
                }
                int rowHeight = reportData[i].Height;

                #region 在此行前分页
                //已有行被添加,前面一行的行后分页属性=true,已有行的总高度>0
                bool breakBeforeThisRow = rows.Count > 0 && reportData[rows[rows.Count - 1]].PageBreak && totalHeight > defaultArea.Height;
                //尺寸超过  条件:加上当前行后超过
                breakBeforeThisRow = breakBeforeThisRow || (setting.RowsPagerStyle == PagerStyle.纸张尺寸分页 && totalHeight + rowHeight > paperHeight);
                //行数超过
                breakBeforeThisRow = breakBeforeThisRow || (setting.RowsPagerStyle == PagerStyle.数据行列数分页 && rows.Count >= setting.RowsPerPage);

                if (breakBeforeThisRow)
                {
                    I3PrintArea area = defaultArea.Clone().AddRows(rows);
                    area.Height = totalHeight;
                    rowPrintAreas.Add(rowPrintAreas.Dic.Count, area);
                    totalHeight = defaultArea.Height + rowHeight;
                    rows.Clear();
                    rows.Add(i);  //不能用i--,如果某行大于整页宽度,会死循环
                    continue;
                }
                #endregion

                //不分页
                totalHeight += rowHeight;
                rows.Add(i);
            }

            //最后有些行未能分页
            if (rows.Count > 0)
            {
                I3PrintArea area = defaultArea.Clone().AddRows(rows);
                area.Height = totalHeight;
                rowPrintAreas.Add(rowPrintAreas.Dic.Count, area);
            }

            return(rowPrintAreas);
        }
 public void ReCalSizeAndPageInfo()
 {
     printAreas = new I3PrintAreas();
     foreach (I3ReportData data in datas)
     {
         data.ReCalSizeAndPageInfo();
         foreach (I3PrintArea area in data.PrintAreas.Dic.Values)
         {
             area.ReportData = data;
             area.Index = printAreas.Dic.Count;
             printAreas.Dic.Add(printAreas.Dic.Count, area);
         }
     }
 }
Exemple #5
0
 internal void SetPrintAreas(I3PrintAreas printAreas)
 {
     this.printAreas = printAreas;
 }