예제 #1
0
        private void InitContent(Text text, int index)
        {
            try
            {
                FarPoint.Win.IBorder border = new FarPoint.Win.LineBorder(Color.Black, 1, text.Attribute.BoundaryLine.LeftBoundaryLine, text.Attribute.BoundaryLine.UpperBoundaryLine, text.Attribute.BoundaryLine.RightBooundaryLine, text.Attribute.BoundaryLine.LowerBoundaryLine);

                int X = text.OriginalLocation.Y1 - 1 + index;
                int Y = text.OriginalLocation.X1 - 1;



                SizeF sizef = report.GraphicsBuffer.MeasureString(text.CellText, text.Attribute.Font);
                if (sizef.Height > sheet.Rows[X].Height && text.RowSpan == 1)
                {
                    sheet.Rows[X].Height = sizef.Height;
                }
                sheet.Cells[X, Y].Text = text.CellText;
                sheet.AddSpanCell(X, Y, text.RowSpan, text.ColumnSpan);

                sheet.Cells[X, Y].Font   = text.Attribute.Font;
                sheet.Cells[X, Y].Border = border;
                sheet.Cells[X, Y].HorizontalAlignment = DesignHelper.ConvertStringAlignmentToHAlignment(text.Attribute.Valign.LineAlignment);
                sheet.Cells[X, Y].VerticalAlignment   = DesignHelper.ConvertStringAlignmentToVAlignment(text.Attribute.Valign.Alignment);

                sheet.Cells[X, Y].Tag = text.Attribute.Diagonal;
            }
            catch
            {
                throw new CellLocationInvalidExcption(text.ToString());
            }
        }
예제 #2
0
        private void InitSheetView()
        {
            try
            {
                sheet.ColumnCount = pageInfo.ContainCols.Count;
                sheet.RowCount    = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        CellStruct cellStruct = dt.Rows[i][j] as CellStruct;
                        if (!CellStruct.IsNullOrEmpty(cellStruct))
                        {
                            //文本内容
                            sheet.Cells[i, j].Text = cellStruct.Context;
                            //字体信息
                            sheet.Cells[i, j].Font = cellStruct.DrawInfo.Font;
                            //边框信息
                            FarPoint.Win.IBorder border = new FarPoint.Win.LineBorder(Color.Black, 1,
                                                                                      cellStruct.DrawInfo.BoundaryLine.LeftBoundaryLine,
                                                                                      cellStruct.DrawInfo.BoundaryLine.UpperBoundaryLine,
                                                                                      cellStruct.DrawInfo.BoundaryLine.RightBooundaryLine,
                                                                                      cellStruct.DrawInfo.BoundaryLine.LowerBoundaryLine);

                            sheet.Cells[i, j].Border = border;
                            //合并信息
                            sheet.Cells[i, j].RowSpan    = cellStruct.ExcelInfo.RowMerge;
                            sheet.Cells[i, j].ColumnSpan = cellStruct.ExcelInfo.ColMerge;

                            //对齐方式
                            sheet.Cells[i, j].HorizontalAlignment = DesignHelper.ConvertStringAlignmentToHAlignment(cellStruct.DrawInfo.Format.LineAlignment);
                            sheet.Cells[i, j].VerticalAlignment   = DesignHelper.ConvertStringAlignmentToVAlignment(cellStruct.DrawInfo.Format.Alignment);
                        }
                    }
                    sheet.Rows[i].Height = pageInfo.PageRowHeight[i];
                }
                for (int i = 0; i < pageInfo.ColumnInfo.Length; i++)
                {
                    sheet.Columns[i].Width = pageInfo.ColumnInfo[i].Width;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }