示例#1
0
        public static void ExportPivotToExcel(RadPivotGrid pivot)
        {        
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "xlsx";
          //  dialog.Filter = "CSV files (*.csv)|*.csv |All Files (*.*) | *.*";

            var result = dialog.ShowDialog();
            if ((bool)result)
            {
                try
                {
                    using (var stream = dialog.OpenFile())
                    {
                        var workbook = GenerateWorkbook(pivot);

                      //  IWorkbookFormatProvider formatProvider = new CsvFormatProvider();
                        //formatProvider.Export(workbook, stream);
                        XlsxFormatProvider provider = new XlsxFormatProvider();
                        provider.Export(workbook, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
          
        }
示例#2
0
        private void ExportToExcel()
        {
            this.BusyIndicator.IsBusy = true;
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.DefaultExt = "xlsx";
            dialog.Filter     = "Excel Workbook (xlsx) | *.xlsx |All Files (*.*) | *.*";

            var result = dialog.ShowDialog();

            if ((bool)result)
            {
                try
                {
                    using (var stream = dialog.OpenFile())
                    {
                        var workbook = GenerateWorkbook();

                        XlsxFormatProvider provider = new XlsxFormatProvider();
                        provider.Export(workbook, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.BusyIndicator.IsBusy = false;
        }
示例#3
0
        public static void ExportPivotToExcel(RadPivotGrid pivot)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.DefaultExt = "xlsx";
            //  dialog.Filter = "CSV files (*.csv)|*.csv |All Files (*.*) | *.*";

            var result = dialog.ShowDialog();

            if ((bool)result)
            {
                try
                {
                    using (var stream = dialog.OpenFile())
                    {
                        var workbook = GenerateWorkbook(pivot);

                        //  IWorkbookFormatProvider formatProvider = new CsvFormatProvider();
                        //formatProvider.Export(workbook, stream);
                        XlsxFormatProvider provider = new XlsxFormatProvider();
                        provider.Export(workbook, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, would you like to create a workbook? [Y/y][N/n]:");

            var result = Console.ReadLine();

            if (result?.ToLower() == "y")
            {
                Workbook  workbook  = new Workbook();
                Worksheet worksheet = workbook.Worksheets.Add();

                CellSelection selection = worksheet.Cells[1, 1]; //B2 cell
                selection.SetValue("Hello RadSpreadProcessing");

                string fileName = "SampleFile.xlsx";

                IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

                using Stream output = new FileStream(fileName, FileMode.Create);

                formatProvider.Export(workbook, output);

                Console.WriteLine("Done!");
            }
        }
示例#5
0
        private static Stream OpenStream(Workbook workbook)
        {
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();
            MemoryStream            stream         = new MemoryStream();

            formatProvider.Export(workbook, stream);
            return(stream);
        }
示例#6
0
        private static void SaveWorkbook(Workbook workbook, Stream stream)
        {
            XlsxFormatProvider provider = new XlsxFormatProvider();

            using (stream)
            {
                provider.Export(workbook, stream);
            }
        }
示例#7
0
        private void ExportXlsx()
        {
            #region radspreadsheet-model-import-export-xlsxformatprovider-wpf_1
            Workbook workbook = new Workbook();
            workbook.Worksheets.Add();
            string fileName = "SampleFile.xlsx";

            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

            using (FileStream output = new FileStream(fileName, FileMode.Create))
            {
                formatProvider.Export(workbook, output);
            }
            #endregion
        }
示例#8
0
        private void ExportSpreadsheet()
        {
            #region radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider_1
            Workbook workbook = new Workbook();
            workbook.Worksheets.Add();
            string fileName = "SampleFile.xlsx";

            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

            using (FileStream output = new FileStream(fileName, FileMode.Create))
            {
                formatProvider.Export(workbook, output);
            }
            #endregion
        }
示例#9
0
        private void SaveFile_Click(object sender, EventArgs e)
        {
            SaveFileDialog     sfd            = new SaveFileDialog();
            XlsxFormatProvider formatProvider = new XlsxFormatProvider();

            sfd.Filter = "Excel Workbook (*xlsx)|*.xlsx|All Files (*.*)|*.*";

            if (sfd.ShowDialog() == true)
            {
                using (Stream output = sfd.OpenFile())
                {
                    formatProvider.Export(this.radSpreadsheet.Workbook, output);
                }
            }
        }
示例#10
0
        protected void btnExportXLSX_Click(object sender, EventArgs e)
        {
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();
            Workbook workbook = createWorkbook();

            byte[] renderedBytes = null;
            using (MemoryStream ms = new MemoryStream()) {
                formatProvider.Export(workbook, ms);
                renderedBytes = ms.ToArray();
            }
            Response.ClearHeaders();
            Response.ClearContent();
            Response.AppendHeader("content-disposition", "attachment; filename=DYEP-RT-Report-" + DateTime.Now.ToString("dd-MM-yyyy") + ".xlsx");
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.BinaryWrite(renderedBytes);
            Response.End();
        }
        private void exportBtn_Click(object sender, EventArgs e)
        {
            var saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            saveFileDialog.ValidateNames    = true;
            saveFileDialog.DereferenceLinks = false;
            saveFileDialog.Filter           = "Excel |*.xlsx";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (Stream output = new FileStream(saveFileDialog.FileName, FileMode.Create))
                {
                    _formatProvider.Export(this.radSpreadsheet1.Workbook, output);
                }
            }
        }
示例#12
0
        public void ExportWorkbookToXlsx()
        {
            #region radspreadsheet-model-import-export-xlsxformatprovider-silverlight_2
            Workbook workbook = new Workbook();
            workbook.Worksheets.Add();

            SaveFileDialog          saveFileDialog = new SaveFileDialog();
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();
            saveFileDialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx|All Files (*.*)|*.*";

            if (saveFileDialog.ShowDialog() == true)
            {
                using (Stream output = saveFileDialog.OpenFile())
                {
                    formatProvider.Export(workbook, output);
                }
            }
            #endregion
        }
示例#13
0
        protected virtual void ExportButton_Click(object sender, EventArgs e)
        {
            if (this.gridControl.MasterViewInfo.IsWaiting)
            {
                RadMessageBox.Show("The Data is not loaded! Please wait!");
                return;
            }

            SaveFileDialog savefile = new SaveFileDialog();

            savefile.FileName = "Document.xlsx";
            savefile.Filter   = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";

            if (savefile.ShowDialog() == DialogResult.OK)
            {
                var formatProvider = new XlsxFormatProvider();

                using (Stream output = new FileStream(savefile.FileName, FileMode.Create))
                {
                    formatProvider.Export(CreateWorkbook(), output);
                }
            }
        }
示例#14
0
        public static void Export(this RadGridView grid, ExportSettings settings)
        {
            var dialog = new SaveFileDialog();

            switch (settings.Format)
            {
                case ExportFormat.Pdf:
                    dialog.DefaultExt = "*.pdf";
                    dialog.Filter = "Adobe PDF 文档 (*.pdf)|*.pdf";
                    break;
                case ExportFormat.Excel:
                    dialog.DefaultExt = "*.xlsx";
                    dialog.Filter = "Excel 工作簿 (*.xlsx)|*.xlsx";
                    break;
                case ExportFormat.Word:
                    dialog.DefaultExt = "*.docx";
                    dialog.Filter = "Word 文档 (*.docx)|*.docx";
                    break;
                case ExportFormat.Csv:
                    dialog.DefaultExt = "*.csv";
                    dialog.Filter = "CSV (逗号分隔) (*.csv)|*.csv";
                    break;
            }

            if (settings.FileName != null)
            {
                dialog.DefaultFileName = settings.FileName;
            }

            if (dialog.ShowDialog() == true)
            {
                switch (settings.Format)
                {
                    case ExportFormat.Csv:
                        using (var output = dialog.OpenFile())
                        {
                            grid.Export(output, new GridViewExportOptions
                                {
                                    Format = Telerik.Windows.Controls.ExportFormat.Csv,
                                    ShowColumnFooters = grid.ShowColumnFooters,
                                    ShowColumnHeaders = grid.ShowColumnHeaders,
                                    ShowGroupFooters = grid.ShowGroupFooters
                                });
                        }
                        break;
                    case ExportFormat.Excel:
                        {
                            var workbook = CreateWorkBook(grid);

                            if (workbook != null)
                            {
                                var provider = new XlsxFormatProvider();
                                using (var output = dialog.OpenFile())
                                {
                                    provider.Export(workbook, output);
                                }
                            }
                        }
                        break;
                    default:
                        {
                            var document = CreateDocument(grid, settings);

                            if (document != null)
                            {
                                document.LayoutMode = DocumentLayoutMode.Paged;
                                document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
                                document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));

                                IDocumentFormatProvider provider = null;

                                switch (settings.Format)
                                {
                                    case ExportFormat.Pdf:
                                        provider = new PdfFormatProvider();
                                        break;
                                    case ExportFormat.Word:
                                        provider = new DocxFormatProvider();
                                        break;
                                }

                                using (var output = dialog.OpenFile())
                                {
                                    if (provider != null) provider.Export(document, output);
                                }
                            }
                        }
                        break;
                }
            }
        }
        public static void Export(this RadGridView grid, ExportSettings settings)
        {
            var dialog = new SaveFileDialog();

            if (settings.Format == ExportFormat.Pdf)
            {
                dialog.DefaultExt = "*.pdf";
                dialog.Filter     = "Adobe PDF Document (*.pdf)|*.pdf";
            }
            else if (settings.Format == ExportFormat.Excel)
            {
                dialog.DefaultExt = "*.xlsx";
                dialog.Filter     = "Excel Workbook (*.xlsx)|*.xlsx";
            }
            else if (settings.Format == ExportFormat.Word)
            {
                dialog.DefaultExt = "*.docx";
                dialog.Filter     = "Word Document (*.docx)|*.docx";
            }
            else if (settings.Format == ExportFormat.Csv)
            {
                dialog.DefaultExt = "*.csv";
                dialog.Filter     = "CSV (Comma delimited) (*.csv)|*.csv";
            }

            if (dialog.ShowDialog() == true)
            {
                if (settings.Format == ExportFormat.Csv)
                {
                    using (var output = dialog.OpenFile())
                    {
                        grid.Export(output, new GridViewExportOptions()
                        {
                            Format            = Telerik.Windows.Controls.ExportFormat.Csv,
                            ShowColumnFooters = grid.ShowColumnFooters,
                            ShowColumnHeaders = grid.ShowColumnHeaders,
                            ShowGroupFooters  = grid.ShowGroupFooters
                        });
                    }
                }
                else
                {
                    if (settings.Format == ExportFormat.Excel)
                    {
                        var workbook = CreateWorkBook(grid, settings);

                        if (workbook != null)
                        {
                            var provider = new XlsxFormatProvider();
                            using (var output = dialog.OpenFile())
                            {
                                provider.Export(workbook, output);
                            }
                        }
                    }
                    else
                    {
                        var document = CreateDocument(grid, settings);

                        if (document != null)
                        {
                            document.LayoutMode = DocumentLayoutMode.Paged;
                            document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
                            document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));

                            IDocumentFormatProvider provider = null;

                            if (settings.Format == ExportFormat.Pdf)
                            {
                                provider = new PdfFormatProvider();
                            }
                            else if (settings.Format == ExportFormat.Word)
                            {
                                provider = new DocxFormatProvider();
                            }

                            using (var output = dialog.OpenFile())
                            {
                                provider.Export(document, output);
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        /// <summary>
        /// Lancement de l'export Excel
        /// </summary>
        /// <param name="parameter"></param>
        public void ExportExcel(object parameter)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "*.xlsx";
            dialog.Filter = string.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", "xlsx", "Excel");

            if (dialog.ShowDialog() == true)
            {
                //Récupération du DataPager pour imprimer toute la grid sans la pagination
                bool paged = ExportAndPrintHelper.GetParameterAtIndex(parameter, ExportAndPrintHelper.RadDataPagerIndex) != null && ExportAndPrintHelper.GetParameterAtIndex(parameter, ExportAndPrintHelper.RadDataPagerIndex) is RadDataPager;

                RadDataPager pager = paged ? (RadDataPager)ExportAndPrintHelper.GetParameterAtIndex(parameter, ExportAndPrintHelper.RadDataPagerIndex) : null;

                int originalPageSize = 0;
                int originalPageIndex = 0;

                if (paged)
                {
                    originalPageSize = pager.PageSize;
                    originalPageIndex = pager.PageIndex;

                    pager.PageSize = 0;
                }

                try
                {

                    RadGridView grid = ExportAndPrintHelper.InverseVisibilityColumnsToExport(parameter,
                        ExportAndPrintHelper.ColumnsToExportIndex, ExportAndPrintHelper.RadGridViewIndex);

                    var workbook = ExportAndPrintHelper.CreateWorkBook(grid);

                    if (workbook != null)
                    {
                        XlsxFormatProvider provider = new XlsxFormatProvider();

                        using (Stream output = dialog.OpenFile())
                        {
                            provider.Export(workbook, output);
                        }
                    }
                }
                catch (OutOfMemoryException ex)
                {
                    throw ex;
                }
                catch (IOException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (paged)
                    {
                        pager.PageSize = originalPageSize;
                        pager.PageIndex = originalPageIndex;
                    }

                    ExportAndPrintHelper.InverseVisibilityColumnsToExport(parameter,
                        ExportAndPrintHelper.ColumnsToExportIndex, ExportAndPrintHelper.RadGridViewIndex);
                }
            }
        }
示例#17
0
        private void Export_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedVertex.Type != VertexType.Interval)
            {
                MessageBox.Show("Mean is undefined for non-interval type node [{0}]." + SelectedVertex);
                return;
            }

            var workbook  = new Workbook();
            var worksheet = workbook.Worksheets.Add();

            worksheet.Name = this.SelectedVertex.Key;

            var template = new WorkSheetTemplate(worksheet);

            template.AddColumn("From", 0, 1);
            template.AddColumn("To", 0, 1);
            template.AddColumn("Mean", 0, this.Table.DateTimes.Count());
            template.AddColumn("Stdv", 0, this.Table.DateTimes.Count());

            var requiredPercentileList = new List <double>();

            if (!string.IsNullOrWhiteSpace(requiredPercentiles))
            {
                var parts = requiredPercentiles.Trim().Split("(),: ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                foreach (var part in parts)
                {
                    double value;
                    if (double.TryParse(part, out value))
                    {
                        requiredPercentileList.Add(value);
                    }
                }
            }

            requiredPercentileList.ForEach(val => template.AddColumn(val.ToString(), 0, this.Table.DateTimes.Count()));

            foreach (var kvp in template.GetColumns())
            {
                if (kvp.Key == "From" || kvp.Key == "To")
                {
                    continue;
                }

                foreach (var dateTime in this.Table.DateTimes)
                {
                    template.AddSubColumn(kvp.Key, dateTime.ToShortDateString(), 1, 1);
                }
            }

            var noOfDateTimes    = this.Table.DateTimes.Count();
            var evidenceRowCount = this.BeliefsData.Values[0].Count;

            for (var row = 0; row < evidenceRowCount; row++)
            {
                worksheet.Cells[row + 2, 0].SetValue(this.BeliefsData[this.SelectedVertex.Key][row]["From"].ToString());
                worksheet.Cells[row + 2, 1].SetValue(this.BeliefsData[this.SelectedVertex.Key][row]["To"].ToString());

                for (var dateTime = 0; dateTime < noOfDateTimes; dateTime++)
                {
                    var colName     = this.Table.DateTimes.ToList()[dateTime].String();
                    var evidence    = (this.BeliefsData[this.SelectedVertex.Key][row][colName] as VertexEvidence);
                    var beliefValue = evidence.Value;
                    var mean        = selectedVertex.Mean(beliefValue);
                    var stdv        = selectedVertex.StandardDeviation(beliefValue);
                    var percentiles = requiredPercentileList.Select(val => new VertexPercentileComputer(val).Compute(this.Network.Vertices[this.SelectedVertex.Key], beliefValue)).ToList();

                    worksheet.Cells[row + 2, template.GetSubColumnPosition("Mean", row + 2)].SetValue(mean);
                    worksheet.Cells[row + 2, template.GetSubColumnPosition("Stdv", row + 2)].SetValue(stdv);

                    requiredPercentileList.ForEach((val, i) => worksheet.Cells[row + 2, template.GetSubColumnPosition(val.ToString(), row + 2)].SetValue(percentiles[i]));
                }
            }

            var dialog = new SaveFileDialog
            {
                Filter = Common.LineData.FileDescription + "|*." + "xlsx",
            };

            var result = dialog.ShowDialog();

            if (result != true)
            {
                return;
            }
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

            using (var output = new FileStream(dialog.FileName, FileMode.Create))
            {
                formatProvider.Export(workbook, output);
            }
        }
示例#18
0
        private static void SaveWorkbook(Workbook workbook, Stream stream)
        {
            XlsxFormatProvider provider = new XlsxFormatProvider();

            using (stream)
            {
                provider.Export(workbook, stream);
            }
        }
示例#19
0
        private void ExportToExcel()
        {
            this.BusyIndicator.IsBusy = true;
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "xlsx";
            dialog.Filter = "Excel Workbook (xlsx) | *.xlsx |All Files (*.*) | *.*";

            var result = dialog.ShowDialog();
            if ((bool)result)
            {
                try
                {
                    using (var stream = dialog.OpenFile())
                    {
                        var workbook = GenerateWorkbook();

                        XlsxFormatProvider provider = new XlsxFormatProvider();
                        provider.Export(workbook, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.BusyIndicator.IsBusy = false;
        }