当前位置: 首页>>代码示例>>C#>>正文


C# RadGridView.Export方法代码示例

本文整理汇总了C#中RadGridView.Export方法的典型用法代码示例。如果您正苦于以下问题:C# RadGridView.Export方法的具体用法?C# RadGridView.Export怎么用?C# RadGridView.Export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RadGridView的用法示例。


在下文中一共展示了RadGridView.Export方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDocument

        private static RadDocument CreateDocument(RadGridView grid)
        {
            RadDocument document = null;

            using (var stream = new MemoryStream())
            {
                grid.Export(stream, new GridViewExportOptions()
                {
                    Format = ExportFormat.Html,
                    ShowColumnFooters = grid.ShowColumnFooters,
                    ShowColumnHeaders = grid.ShowColumnHeaders,
                    ShowGroupFooters = grid.ShowGroupFooters
                });

                stream.Position = 0;
                document = new HtmlFormatProvider().Import(stream);
            }

            return document;
        }
开发者ID:stevenh77,项目名称:ExportToPdf,代码行数:20,代码来源:MainPage.xaml.cs

示例2: OnExport

        private void OnExport(object sender)
        {
            var menu = sender as RadMenuItem;
            IsContextMenuOpen = false;
            if (menu != null && menu.Header.ToString().Equals("导出源数据", StringComparison.OrdinalIgnoreCase))
            {
                if (menu.Name.Equals("TrendGridData", StringComparison.OrdinalIgnoreCase))
                {
                    //创建RadGridView
                    var columnsList = new Dictionary<string, string>
                    {
                        {"DateTime", "时间点"},
                        {"AircraftType", "机型"},
                        {"AirNum", "飞机数"},
                        {"Amount", "期末飞机数"}
                    };
                    _exportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList,
                        FleetAircraftTypeTrendCollection, "FleetStructure");

                    _i = 1;
                    _exportRadgridview.ElementExporting -= ElementExporting;
                    _exportRadgridview.ElementExporting += ElementExporting;
                    using (
                        var stream = ImageAndGridOperation.DowmLoadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc")
                        )
                    {
                        if (stream != null)
                        {
                            _exportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name.Equals("RegionalPieGridData", StringComparison.OrdinalIgnoreCase))
                {
                    if (FleetAircraftRegionalCollection == null || !FleetAircraftRegionalCollection.Any())
                    {
                        return;
                    }

                    //创建RadGridView
                    var columnsList = new Dictionary<string, string> {{"AircraftType", "座级"}, {"AirNum", "飞机数"}};
                    _exportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList,
                        FleetAircraftRegionalCollection, "RegionalPieStructure");

                    _i = 1;
                    _exportRadgridview.ElementExporting -= ElementExporting;
                    _exportRadgridview.ElementExporting += ElementExporting;
                    using (
                        var stream = ImageAndGridOperation.DowmLoadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc")
                        )
                    {
                        if (stream != null)
                        {
                            _exportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name.Equals("TypePieGridData", StringComparison.OrdinalIgnoreCase))
                {
                    if (FleetAircraftTypeCollection == null || !FleetAircraftTypeCollection.Any())
                    {
                        return;
                    }

                    //创建RadGridView
                    var columnsList = new Dictionary<string, string> {{"AircraftType", "机型"}, {"AirNum", "飞机数(架)"}};
                    _exportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList,
                        FleetAircraftTypeCollection, "TypePieStructure");

                    _i = 1;
                    _exportRadgridview.ElementExporting -= ElementExporting;
                    _exportRadgridview.ElementExporting += ElementExporting;
                    using (
                        var stream = ImageAndGridOperation.DowmLoadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc")
                        )
                    {
                        if (stream != null)
                        {
                            _exportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
            }
            else if (menu != null && menu.Header.ToString().Equals("导出图片", StringComparison.OrdinalIgnoreCase))
            {
                if (menu.Name.Equals("TrendGridImage", StringComparison.OrdinalIgnoreCase))
                {
                    //导出图片
                    if (_lineGrid != null)
                    {
                        Commonmethod.ExportToImage(_lineGrid.Parent as Grid);
                    }
                }
                else if (menu.Name.Equals("RegionalPieGridImage", StringComparison.OrdinalIgnoreCase))
                {
                    //导出图片
                    if (_regionalPieGrid != null)
                    {
                        Commonmethod.ExportToImage(_regionalPieGrid);
                    }
//.........这里部分代码省略.........
开发者ID:unicloud,项目名称:FRP,代码行数:101,代码来源:FleetStructureVm.cs

示例3: OnExport

        private void OnExport(object sender)
        {
            RadMenuItem menu = sender as RadMenuItem;
            IsContextMenuOpen = false;
            if (menu != null && menu.Header.ToString() == "导出源数据")
            {

                if (menu.Name == "LineGridData")
                {
                    if (_service.CurrentAirlines.SubAirlines != null && _service.CurrentAirlines.SubAirlines.Any(p => p.SubType == 1))
                    {
                        //当包含子公司时
                        Dictionary<string, string> columnsList = new Dictionary<string, string>();
                        columnsList.Add("DateTime", "时间点");
                        columnsList.Add("AircraftAmount", "期末货机数(子)");
                        columnsList.Add("AircraftAmount1", "期末货机数");
                        columnsList.Add("LoadAmount", "期末商载量(子)");
                        columnsList.Add("LoadAmount1", "期末商载量");
                        ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftTrendLineCollection, "SubFleetTrendCargo");
                    }
                    else
                    {
                        //创建RadGridView
                        Dictionary<string, string> columnsList = new Dictionary<string, string>();
                        columnsList.Add("DateTime", "时间点");
                        columnsList.Add("AircraftAmount1", "期末货机数");
                        columnsList.Add("LoadAmount1", "期末商载量");
                        ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftTrendLineCollection, "FleetTrendCargo");
                    }
                    i = 1;
                    ExportRadgridview.ElementExporting -= this.ElementExporting;
                    ExportRadgridview.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(ElementExporting);
                    using (Stream stream = ImageAndGridOperation.DownloadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            ExportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name == "BarGridData")
                {
                    if (_service.CurrentAirlines.SubAirlines != null && _service.CurrentAirlines.SubAirlines.Any(p => p.SubType == 1))
                    {
                        //当包含子公司时
                        Dictionary<string, string> columnsList = new Dictionary<string, string>();
                        columnsList.Add("DateTime", "时间点");
                        columnsList.Add("AircraftAmount", "货机净增数(子)");
                        columnsList.Add("AircraftAmount1", "货机净增数(子)");
                        columnsList.Add("LoadAmount", "商载净增量(子)");
                        columnsList.Add("LoadAmount1", "商载净增量");
                        ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftTrendBarCollection, "SubFleetTrendCargo");
                    }
                    else
                    {
                        //创建RadGridView
                        Dictionary<string, string> columnsList = new Dictionary<string, string>();
                        columnsList.Add("DateTime", "时间点");
                        columnsList.Add("AircraftAmount", "货机净增数");
                        columnsList.Add("LoadAmount", "商载净增量");
                        ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftTrendBarCollection, "FleetTrendCargo");
                    }
                    i = 1;
                    ExportRadgridview.ElementExporting -= this.ElementExporting;
                    ExportRadgridview.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(ElementExporting);
                    using (Stream stream = ImageAndGridOperation.DownloadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            ExportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name == "AircraftPieGridData")
                {
                    if (FleetAircraftCollection == null || FleetAircraftCollection.Count() == 0)
                    {
                        return;
                    }

                    //创建RadGridView
                    Dictionary<string, string> columnsList = new Dictionary<string, string>();
                    columnsList.Add("Aircraft", "航空公司");
                    columnsList.Add("Amount", "飞机数(架)");
                    ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftCollection, "PieFleetTrend");

                    i = 1;
                    ExportRadgridview.ElementExporting -= this.ElementExporting;
                    ExportRadgridview.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(ElementExporting);
                    using (Stream stream = ImageAndGridOperation.DownloadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            ExportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name == "LoadPieGridData")
                {
                    if (FleetLoadCollection == null || FleetLoadCollection.Count() == 0)
//.........这里部分代码省略.........
开发者ID:unicloud,项目名称:AFRP,代码行数:101,代码来源:AfrpFleetTrendCargoViewModel.cs

示例4: CreateDocument

        public static RadDocument CreateDocument(RadGridView grid)
        {
            RadDocument document = null;

            using (var stream = new MemoryStream())
            {
                grid.ElementExporting += elementExporting;

                grid.Export(stream, new GridViewExportOptions()
                {
                    Format = ExportFormat.Html,
                    ShowColumnFooters = grid.ShowColumnFooters,
                    ShowColumnHeaders = grid.ShowColumnHeaders,
                    ShowGroupFooters = grid.ShowGroupFooters,
                    Culture = new CultureInfo("fr-FR"),
                    Items = grid.Items
                });

                grid.ElementExporting -= elementExporting;

                stream.Position = 0;

                HtmlFormatProvider provider = new HtmlFormatProvider();
                document = new HtmlFormatProvider().Import(stream);
                document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(20);
                document.LayoutMode = DocumentLayoutMode.Paged;
                document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
                document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
            }

            return document;
        }
开发者ID:JeanNguon,项目名称:Projet,代码行数:32,代码来源:ExportAndPrintHelper.cs

示例5: CreateWorkBook

        public static Workbook CreateWorkBook(RadGridView grid)
        {
            Workbook book = null;

            using (var stream = new MemoryStream())
            {
                int index = 0;
                foreach (GroupDescriptor group in grid.GroupDescriptors)
                {
                    grid.Columns.Insert(index++, new GridViewDataColumn() { DataMemberBinding = new System.Windows.Data.Binding(group.Member) });
                }

                grid.ElementExporting += elementExporting;

                var exportOptions = new GridViewExportOptions()
                {
                    Format = ExportFormat.Csv,
                    ShowColumnFooters = grid.ShowColumnFooters,
                    ShowColumnHeaders = grid.ShowColumnHeaders,
                    ShowGroupFooters = grid.ShowGroupFooters,
                    Culture = new CultureInfo("fr-FR"),
                    Items = grid.Items
                };
                grid.Export(stream, exportOptions);

                grid.ElementExporting -= elementExporting;

                stream.Position = 0;

                var csvProvider = new CsvFormatProvider();
                book = csvProvider.Import(stream);

                // /!\ telerik date format workaround
                var pattern = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;
                var dateCellFormat = new CellValueFormat(pattern);

                var dateColsIdx = grid.Columns.Cast<GridViewColumn>().OfType<GridViewDataColumn>().Where(col => col.DataType == typeof(DateTime)).Select(col => col.DisplayIndex).ToList();

                if (dateColsIdx.Any())
                {
                    var skipFirstRow = true;
                    var rowCount = grid.Items.Count;
                    for (int i = skipFirstRow ? 1 : 0; i < rowCount; i++)
                    {
                        foreach (var colIdx in dateColsIdx)
                        {
                            book.Worksheets[0].Cells[i, colIdx].SetFormat(dateCellFormat);
                        }
                    }
                }

                foreach (GroupDescriptor group in grid.GroupDescriptors)
                {
                    grid.Columns.RemoveAt(0);
                }
            }

            return book;
        }
开发者ID:JeanNguon,项目名称:Projet,代码行数:59,代码来源:ExportAndPrintHelper.cs

示例6: OnExport

        private void OnExport(object sender)
        {
            var radMenuItem = sender as RadMenuItem;
            IsContextMenuOpen = false;
            if (radMenuItem != null && radMenuItem.Header.ToString().Equals("导出源数据", StringComparison.OrdinalIgnoreCase))
            {
                if (radMenuItem.Name.Equals("LineGridData", StringComparison.OrdinalIgnoreCase))
                {
                    //创建RadGridView
                    var columnsList = new Dictionary<string, string>
                    {
                        {"DateTime", "时间点"},
                        {"AircraftAmount", "期末客机数"},
                        {"SeatAmount", "期末座位数"},
                        {"LoadAmount", "期末商载量"}
                    };
                    _exportRadGridView = ImageAndGridOperation.CreatDataGridView(columnsList,
                        FleetAircraftTrendLineCollection, "FleetTrendPnr");
                    _i = 1;
                    _exportRadGridView.ElementExporting -= ElementExporting;
                    _exportRadGridView.ElementExporting += ElementExporting;
                    using (
                        var stream = ImageAndGridOperation.DowmLoadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc")
                        )
                    {
                        if (stream != null)
                        {
                            _exportRadGridView.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (radMenuItem.Name.Equals("BarGridData", StringComparison.OrdinalIgnoreCase))
                {
                    //创建RadGridView
                    var columnsList = new Dictionary<string, string>
                    {
                        {"DateTime", "时间点"},
                        {"AircraftAmount", "客机净增数"},
                        {"SeatAmount", "座位净增数"},
                        {"LoadAmount", "商载净增量"}
                    };
                    _exportRadGridView = ImageAndGridOperation.CreatDataGridView(columnsList,
                        FleetAircraftTrendBarCollection, "FleetTrendPnr");
                    _i = 1;
                    _exportRadGridView.ElementExporting -= ElementExporting;
                    _exportRadGridView.ElementExporting += ElementExporting;
                    using (
                        var stream = ImageAndGridOperation.DowmLoadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc")
                        )
                    {
                        if (stream != null)
                        {
                            _exportRadGridView.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (radMenuItem.Name.Equals("AircraftPieGridData", StringComparison.OrdinalIgnoreCase))
                {
                    if (FleetAircraftCollection == null || !FleetAircraftCollection.Any())
                    {
                        return;
                    }

                    //创建RadGridView
                    var columnsList = new Dictionary<string, string> {{"Aircraft", "航空公司"}, {"Amount", "飞机数(架)"}};
                    _exportRadGridView = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftCollection,
                        "PieFleetTrend");

                    _i = 1;
                    _exportRadGridView.ElementExporting -= ElementExporting;
                    _exportRadGridView.ElementExporting += ElementExporting;
                    using (
                        var stream =
                            ImageAndGridOperation.DowmLoadDialogStream(
                                "文档文件(*.xls)|*.xls|文档文件(*.xlsx)|*.xlsx|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            _exportRadGridView.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (radMenuItem.Name.Equals("SeatPieGridData", StringComparison.OrdinalIgnoreCase))
                {
                    if (FleetSeatCollection == null || !FleetSeatCollection.Any())
                    {
                        return;
                    }

                    //创建RadGridView
                    var columnsList = new Dictionary<string, string> {{"Aircraft", "航空公司"}, {"Amount", "座位数"}};
                    _exportRadGridView = ImageAndGridOperation.CreatDataGridView(columnsList, FleetSeatCollection,
                        "PieFleetTrend");

                    _i = 1;
                    _exportRadGridView.ElementExporting -= ElementExporting;
                    _exportRadGridView.ElementExporting += ElementExporting;
                    using (
                        var stream = ImageAndGridOperation.DowmLoadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc")
                        )
//.........这里部分代码省略.........
开发者ID:unicloud,项目名称:FRP,代码行数:101,代码来源:PassengerAircraftTrendVm.cs

示例7: OnExport

        private void OnExport(object sender)
        {
            RadMenuItem menu = sender as RadMenuItem;
            IsContextMenuOpen = false;
            if (menu != null && menu.Header.ToString() == "导出源数据")
            {
                if (menu.Name == "TrendGridData")
                {
                    //创建RadGridView
                    Dictionary<string, string> columnsList = new Dictionary<string, string>();
                    columnsList.Add("DateTime", "时间点");
                    columnsList.Add("AircraftType", "机型");
                    columnsList.Add("AirNum", "飞机数");
                    columnsList.Add("Amount", "期末飞机数");
                    ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftTypeTrendCollection, "FleetStructure");

                    i = 1;
                    ExportRadgridview.ElementExporting -= this.ElementExporting;
                    ExportRadgridview.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(ElementExporting);
                    using (Stream stream = ImageAndGridOperation.DownloadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            ExportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name == "RegionalPieGridData")
                {
                    if (FleetAircraftRegionalCollection == null || FleetAircraftRegionalCollection.Count() == 0)
                    {
                        return;
                    }

                    //创建RadGridView
                    Dictionary<string, string> columnsList = new Dictionary<string, string>();
                    columnsList.Add("AircraftType", "座级");
                    columnsList.Add("AirNum", "飞机数");
                    ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftRegionalCollection, "RegionalPieStructure");

                    i = 1;
                    ExportRadgridview.ElementExporting -= this.ElementExporting;
                    ExportRadgridview.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(ElementExporting);
                    using (Stream stream = ImageAndGridOperation.DownloadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            ExportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
                else if (menu.Name == "TypePieGridData")
                {
                    if (FleetAircraftTypeCollection == null || FleetAircraftTypeCollection.Count() == 0)
                    {
                        return;
                    }

                    //创建RadGridView
                    Dictionary<string, string> columnsList = new Dictionary<string, string>();
                    columnsList.Add("AircraftType", "机型");
                    columnsList.Add("AirNum", "飞机数(架)");
                    ExportRadgridview = ImageAndGridOperation.CreatDataGridView(columnsList, FleetAircraftTypeCollection, "TypePieStructure");

                    i = 1;
                    ExportRadgridview.ElementExporting -= this.ElementExporting;
                    ExportRadgridview.ElementExporting += new EventHandler<GridViewElementExportingEventArgs>(ElementExporting);
                    using (Stream stream = ImageAndGridOperation.DownloadDialogStream("文档文件(*.xls)|*.xls|文档文件(*.doc)|*.doc"))
                    {
                        if (stream != null)
                        {
                            ExportRadgridview.Export(stream, ImageAndGridOperation.SetGridViewExportOptions());
                        }
                    }
                }
            }
            else if (menu != null && menu.Header.ToString() == "导出图片")
            {
                if (menu.Name == "TrendGridImage")
                {
                    //导出图片
                    if (this.LineGrid != null)
                    {
                        commonmethod.ExportToImage(this.LineGrid.Parent as Grid);
                    }
                }
                else if (menu.Name == "RegionalPieGridImage")
                {
                    //导出图片
                    if (this.RegionalPieGrid != null)
                    {
                        commonmethod.ExportToImage(this.RegionalPieGrid);
                    }
                }
                else if (menu.Name == "TypePieGridImage")
                {
                    //导出图片
                    if (this.TypePieGrid != null)
                    {
                        commonmethod.ExportToImage(this.TypePieGrid);
//.........这里部分代码省略.........
开发者ID:unicloud,项目名称:AFRP,代码行数:101,代码来源:AfrpFleetStructureViewModel.cs


注:本文中的RadGridView.Export方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。