コード例 #1
0
        public XlsDef Build()
        {
            var def = new XlsDef();

            try
            {
                def.Style.FontName = "Arial Narrow";
                var title = def.AddArea().AddRow().AddText(Form.Caption);
                title.Style.FontDSize  = 2;
                title.Style.FontStyle  = FontStyle.Bold;
                title.Style.FontColor  = IndexedColors.DARK_BLUE.Index; // 18;
                title.Style.HAlign     = HAlignment.Center;
                title.Style.AutoHeight = true;

                def.AddArea().AddEmptyRow();

                var hRow = def.AddArea().AddRow();
                hRow.ShowAllBorders(true);
                hRow.Style.FontStyle = FontStyle.Bold;
                hRow.Style.HAlign    = HAlignment.Center;
                hRow.Style.BgColor   = IndexedColors.BLUE_GREY.Index; //48;
                hRow.Style.FontColor = IndexedColors.WHITE.Index;
                hRow.Style.WrapText  = true;

                var ds   = ((DataSet)DataSet ?? SqlDataSet);
                var dRow = def.AddGrid(ds).AddRow();
                dRow.ShowAllBorders(true);
                dRow.Style.AutoWidth = true;

                if (Form.Children != null)
                {
                    foreach (var control in Form.Children)
                    {
                        AddControlBand(hRow, dRow, control);
                    }
                }
                title.ColSpan = dRow.GetCols();

                return(def);
            }
            catch
            {
                def.Dispose();
                throw;
            }
        }
コード例 #2
0
        protected XlsDef Build()
        {
            var def = new XlsDef();

            try
            {
                AdjustDocListForms(Form);
                _adjuster.Adjust();
                _captionColSpan = _adjuster.GetColumnSpanForPercent(50);
                _valueColSpan   = Math.Max(_adjuster.ColumnCount - _captionColSpan, 1);

                def.Style.FontName   = "Arial Narrow";
                def.DefaultRowHeight = 13;

                var cell = def.AddArea().AddRow().AddText(Form.Caption);
                cell.Style.FontDSize  = 2;
                cell.Style.FontStyle  = FontStyle.Bold;
                cell.Style.FontColor  = IndexedColors.DARK_BLUE.Index; // 18;
                cell.Style.HAlign     = HAlignment.Center;
                cell.Style.AutoHeight = true;
                cell.ColSpan          = _adjuster.ColumnCount;

                def.AddArea().AddEmptyRow();

//                var area = def.AddArea();

                if (Form.Children != null)
                {
                    foreach (var control in Form.Children)
                    {
                        AddControlRow(def, /*area,*/ control);
                    }
                }

                def.ColumnWidths = _adjuster.ColumnSizes;

                return(def);
            }
            catch
            {
                def.Dispose();
                throw;
            }
        }
コード例 #3
0
        public XlsDef Build()
        {
            var def = new XlsDef();

            try
            {
                AdjustDocListForms(Report);
                _adjuster.Adjust();

                def.Style.FontName = "Arial Narrow";
                def.AddArea().AddEmptyRow();

                var headArea = def.AddArea();
                BuildSections(headArea, Headers);

                def.AddArea().AddEmptyRow();

                var hRow = def.AddArea().AddRow();
                hRow.ShowAllBorders(true);
                hRow.Style.FontStyle = FontStyle.Bold;
                hRow.Style.HAlign    = HAlignment.Center;
                hRow.Style.BgColor   = IndexedColors.BLUE_GREY.Index; //48;
                hRow.Style.FontColor = IndexedColors.WHITE.Index;
                hRow.Style.WrapText  = true;

                var dRow = def.AddGrid(SqlDataSet).AddRow();
                dRow.ShowAllBorders(true);
                dRow.Style.WrapText = true;

                var sourceMap = MapSources();
                if (Report.Columns != null)
                {
                    foreach (var column in Report.Columns)
                    {
                        AddColumn(hRow, dRow, column, sourceMap);
                    }
                }

                def.AddArea().AddEmptyRow();
                var footArea = def.AddArea();
                BuildSections(footArea, Footers);

                def.ColumnWidths = _adjuster.ColumnSizes;

                return(def);
            }
            catch
            {
                def.Dispose();
                throw;
            }
        }
コード例 #4
0
        public XlsDef Build()
        {
            var def = new XlsDef();

            try
            {
                AdjustDocListForms(Form);
                _adjuster.Adjust();

                def.Style.FontName = "Arial Narrow";

                /*var title = def.AddArea().AddRow().AddText(Form.Caption);
                 * title.Style.FontDSize = 2;
                 * title.Style.FontStyle = FontStyle.Bold;
                 * title.Style.FontColor = IndexedColors.DARK_BLUE.Index; // 18;
                 * title.Style.HAlign = HAlignment.Center;
                 * title.Style.AutoHeight = true;*/

                def.AddArea().AddEmptyRow();

                var headArea = def.AddArea();
                BuildSections(headArea, Headers);

                def.AddArea().AddEmptyRow();

                var hRow = def.AddArea().AddRow();
                hRow.ShowAllBorders(true);
                hRow.Style.FontStyle = FontStyle.Bold;
                hRow.Style.HAlign    = HAlignment.Center;
                hRow.Style.BgColor   = IndexedColors.BLUE_GREY.Index; //48;
                hRow.Style.FontColor = IndexedColors.WHITE.Index;
                hRow.Style.WrapText  = true;

                var ds   = ((DataSet)DataSet ?? SqlDataSet);
                var dRow = def.AddGrid(ds).AddRow();
                dRow.ShowAllBorders(true);
                dRow.Style.WrapText = true;

                if (Form.Children != null)
                {
                    foreach (var control in Form.Children)
                    {
                        AddControlBand(hRow, dRow, control);
                    }
                }

                def.AddArea().AddEmptyRow();
                var footArea = def.AddArea();
                BuildSections(footArea, Footers);

                def.ColumnWidths = _adjuster.ColumnSizes;

                //title.ColSpan = dRow.GetCols();

                return(def);
            }
            catch
            {
                def.Dispose();
                throw;
            }
        }
コード例 #5
0
        private void AddControlRow(XlsDef def, /*XlsGroup band,*/ BizControl control)
        {
            if (control.Invisible || control is BizButton)
            {
                return;
            }

            if (control is BizPanel || control is BizDocumentControl)
            {
                var cell = def.AddArea().AddRow().AddText(control.Caption); //band.AddGroup(new XlsRow()).AddText(control.Caption);
                cell.Style.FontStyle  = FontStyle.Bold;
                cell.ColSpan          = _adjuster.ColumnCount;
                cell.Style.FontColor  = IndexedColors.DARK_BLUE.Index; // 18;
                cell.Style.HAlign     = HAlignment.Center;
                cell.Style.AutoHeight = true;
                cell.Style.BgColor    = IndexedColors.GREY_25_PERCENT.Index;

                foreach (var child in control.Children)
                {
                    AddControlRow(def, /*band,*/ child);
                }
            }
            else if (control is BizDocumentListForm)
            {
                var docListForm = (BizDocumentListForm)control;

                var cell = def.AddArea().AddRow().AddText(control.Caption);
                cell.Style.FontStyle  = FontStyle.Bold;
                cell.ColSpan          = _adjuster.ColumnCount;
                cell.Style.FontColor  = IndexedColors.DARK_BLUE.Index; // 18;
                cell.Style.HAlign     = HAlignment.Center;
                cell.Style.AutoHeight = true;
                cell.Style.BgColor    = IndexedColors.GREY_25_PERCENT.Index;

                var tableForm = docListForm.Children != null && docListForm.Children.Count > 0
                    ? docListForm
                    : (BizControl)docListForm.TableForm;
                var docDefId = docListForm.TableForm != null
                    ? docListForm.TableForm.DocumentDefId ?? Guid.Empty
                    : Guid.Empty;

                SqlQueryDataSet dataSet;
                var             sqb = _sqlQueryBuilderFactory.Create();
                if (docListForm.AttributeDefId != null)
                {
                    /*using (
                     *  var query = SqlQueryExBuilder.BuildAttrList(tableForm,
                     *      docListForm.DocumentId ?? Guid.Empty, docDefId, (Guid) docListForm.AttributeDefId, null,
                     *      null,
                     *      UserId, DataContext))*/
                    /*using (*/
                    var query = sqb.BuildAttrList(tableForm, docListForm.DocumentId ?? Guid.Empty, docDefId,
                                                  (Guid)docListForm.AttributeDefId, null, null);//)
                    {
                        query.WithNoLock = true;

                        dataSet = CreateDataSet(query);
                    }
                }
                else if (docListForm.FormAttributeDefId != null)
                {
                    /*using (
                     *  var query = SqlQueryExBuilder.BuildRefList(tableForm,
                     *      docListForm.DocumentId ?? Guid.Empty, docDefId, (Guid) docListForm.FormAttributeDefId, null,
                     *      null,
                     *      UserId, DataContext))*/
                    //using (
                    var query = sqb.BuildRefList(tableForm,
                                                 docListForm.DocumentId ?? Guid.Empty, docDefId, (Guid)docListForm.FormAttributeDefId, null,
                                                 null);//)
                    {
                        dataSet = CreateDataSet(query);
                    }
                }
                else
                {
                    throw new ApplicationException(
                              "Недостаточно данных для формирования Excel-файла. Ошибка в данных формы!");
                }

                /*int count;
                 *  var docs = docRepo.DocAttrListById(out count, docListForm.DocumentId ?? Guid.Empty,
                 *      docListForm.AttributeDefId ?? Guid.Empty, 0, 0);
                 *
                 *  dataSet = new DocFormDataSet(docs, tableForm, UserId, DataContext);*/

                var hRow = def.AddArea().AddRow();
                hRow.ShowAllBorders(true);
                hRow.Style.FontStyle = FontStyle.Bold;
                hRow.Style.HAlign    = HAlignment.Center;
                hRow.Style.BgColor   = IndexedColors.BLUE_GREY.Index; //48;
                hRow.Style.FontColor = IndexedColors.WHITE.Index;
                hRow.Style.WrapText  = true;
                var dRow = def.AddGrid(dataSet).AddRow();
                dRow.ShowAllBorders(true);

                if (tableForm.Children != null)
                {
                    foreach (var child in tableForm.Children)
                    {
                        AddControlBand(hRow, dRow, child, dataSet);
                    }
                }
            }
            else
            {
                var row  = def.AddArea().AddRow();//band.AddGroup(new XlsRow());
                var cell = row.AddText(control.Caption);
                cell.ColSpan        = _captionColSpan;
                cell.Style.HAlign   = HAlignment.Right;
                cell.Style.WrapText = true;

                if (control is BizDataControl && ((BizDataControl)control).ObjectValue != null)
                {
                    var value    = GetDataControlValue((BizDataControl)control);
                    var dataCell = row.AddText(value);
                    dataCell.ColSpan         = _valueColSpan;
                    dataCell.Style.FontColor = IndexedColors.DARK_BLUE.Index;
                    dataCell.Style.WrapText  = true;
                }
                else
                {
                    var emptyCell = row.AddEmptyCell();
                    emptyCell.ColSpan = _valueColSpan;
                }
            }
        }
コード例 #6
0
        public XlsDef Build()
        {
            var def = new XlsDef();

            try
            {
                AdjustReportColumns(Table);
                _adjuster.Adjust();

                def.Style.FontName = "Arial Narrow";
                def.AddArea().AddEmptyRow();

                var headArea = def.AddArea();
                BuildSections(headArea, Headers);

                def.AddArea().AddEmptyRow();

                var hRow = def.AddArea().AddRow();
                hRow.ShowAllBorders(true);
                hRow.Style.FontStyle = FontStyle.Bold;
                hRow.Style.HAlign    = HAlignment.Center;
                hRow.Style.BgColor   = IndexedColors.BLUE_GREY.Index; //48;
                hRow.Style.FontColor = IndexedColors.WHITE.Index;
                hRow.Style.WrapText  = true;

                var dRow = def.AddArea().AddRow();
                dRow.ShowAllBorders(true);
                dRow.Style.WrapText = true;

                if (Report.Columns != null)
                {
                    BuildHeaderColumns(hRow, dRow);

                    foreach (var row in Table.Rows)
                    {
                        dRow = def.AddArea().AddRow();
                        dRow.ShowAllBorders(true);
                        dRow.Style.WrapText = true;
                        AddRow(dRow, row);
                    }
                    // Add Summary Row
                    dRow = def.AddArea().AddRow();
                    dRow.ShowAllBorders(true);
                    dRow.Style.WrapText  = true;
                    dRow.Style.FontStyle = FontStyle.Bold;

                    var summaries = Table.GetColumnSummaries();
                    foreach (var data in summaries)
                    {
                        if (data is int)
                        {
                            dRow.AddInt((int)data);
                        }
                        else if (data is double)
                        {
                            dRow.AddFloat((double)data);
                        }
                        else
                        {
                            dRow.AddEmptyCell();
                        }
                    }
                    dRow.Style.AutoHeight = true;
                }
                def.AddArea().AddEmptyRow();
                var footArea = def.AddArea();
                BuildSections(footArea, Footers);

                def.ColumnWidths = _adjuster.ColumnSizes;

                return(def);
            }
            catch
            {
                def.Dispose();
                throw;
            }
        }