Ejemplo n.º 1
0
        /// <summary>
        /// Called by the UI when the document is ready for display.
        /// </summary>
        /// <param name="presenter">The presenter used to display the document.</param>
        public virtual void Init(IDocumentPresenter presenter)
        {
            if (presenter == null)
                throw new ArgumentNullException("presenter");

            Presenter = presenter;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called by the UI when the document is ready for display.
        /// </summary>
        /// <param name="presenter">The presenter used to display the document.</param>
        public virtual void Init(IDocumentPresenter presenter)
        {
            if (presenter == null)
            {
                throw new ArgumentNullException("presenter");
            }

            Presenter = presenter;
        }
Ejemplo n.º 3
0
        public void PrepareExport(GridControl grid, bool exportColors, HashSet <GridColumn> excludeColumn,
                                  Action <ExcelExportData, IDocumentPresenter, ExcelExportProgressCommand> afterExportComplete,
                                  ExcelExportProgressCommand progressCommand, IDocumentPresenter document)
        {
            Rows = grid.VisibleRowCount;
            progressCommand.Rows       = Rows;
            progressCommand.CurrentRow = 0;
            var tv = grid.View as TableView;
            var eo = new ExcelExportObject
            {
                VisibleColumns =
                    grid.Columns.Where(
                        c => !excludeColumn.Contains(c) && !(c is GridExpandColumn) && c.Visible)
                    .OrderBy(c => c.VisibleIndex)
                    .ToList(),
                RowBrushes          = new Brush[grid.VisibleRowCount],
                CurrentRow          = 0,
                PrevRow             = 0,
                ExportColors        = exportColors && tv != null,
                Grid                = grid,
                RowData             = new List <object>(),
                ProgressCommand     = progressCommand,
                AfterExportComplete = afterExportComplete,
                Document            = document
            };

            Headers = new RealColumnHeadersCollection(eo.VisibleColumns.Select(c => GetHeaderString(c.Header)).ToArray());
            Columns = eo.VisibleColumns.Count;
            NumberFormatting.ClearFormats();
            for (int i = 0; i < eo.VisibleColumns.Count; i++)
            {
                NumberFormatting.AddFormat(i, eo.VisibleColumns[i].FieldType);
            }
            eo.CellBrushes = new Brush[grid.VisibleRowCount, eo.VisibleColumns.Count];
            eo.Cells       = new string[grid.VisibleRowCount, eo.VisibleColumns.Count];
            if (eo.ExportColors)
            {
                eo.PhantomCells = new CellContentPresenter[32, Columns];
                eo.PhantomRows  = new GridRowContent[32];
                for (int i = 0; i < 32; i++)
                {
                    eo.PhantomRows[i] = new GridRowContent()
                    {
                        Style = tv.RowStyle
                    };
                    for (int j = 0; j < Columns; j++)
                    {
                        eo.PhantomCells[i, j] = new CellContentPresenter {
                            Style = eo.VisibleColumns[j].CellStyle
                        }
                    }
                    ;
                }
            }

            DoExport(eo);
        }