Пример #1
0
        private void RunExportToHTML(string fileName, ref bool openExportFile)
        {
            ExportToHTML htmlExporter = new ExportToHTML(this.radGridView1);

            switch (this.radComboBoxSummaries.SelectedIndex)
            {
            case 0:
                htmlExporter.SummariesExportOption = SummariesOption.ExportAll;
                break;

            case 1:
                htmlExporter.SummariesExportOption = SummariesOption.ExportOnlyTop;
                break;

            case 2:
                htmlExporter.SummariesExportOption = SummariesOption.ExportOnlyBottom;
                break;

            case 3:
                htmlExporter.SummariesExportOption = SummariesOption.DoNotExport;
                break;
            }

            //set export settings
            htmlExporter.ExportVisualSettings = this.radCheckBoxExportVisual.IsChecked;
            htmlExporter.ExportHierarchy      = this.radCheckBoxExportHierarchy.IsChecked;
            htmlExporter.HiddenColumnOption   = HiddenOption.DoNotExport;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                htmlExporter.RunExport(fileName);

                RadMessageBox.SetThemeName(this.radGridView1.ThemeName);
                DialogResult dr = RadMessageBox.Show("The data in the grid was exported successfully. Do you want to open the file?",
                                                     "Export to HTML", MessageBoxButtons.YesNo, RadMessageIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    openExportFile = true;
                }
            }
            catch (IOException ex)
            {
                RadMessageBox.SetThemeName(this.radGridView1.ThemeName);
                RadMessageBox.Show(this, ex.Message, "I/O Error", MessageBoxButtons.OK, RadMessageIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        public static void RunExportToHTML(string fileName, RadGridView radGridView)
        {
            ExportToHTML htmlExporter = new ExportToHTML(radGridView);

            htmlExporter.HTMLCellFormatting += htmlExporter_HTMLCellFormatting;

            htmlExporter.SummariesExportOption = SummariesOption.ExportAll;

            //set export settings
            //htmlExporter.ExportVisualSettings = this.radCheckBoxExportVisual.IsChecked;
            //htmlExporter.ExportHierarchy = this.radCheckBoxExportHierarchy.IsChecked;
            htmlExporter.HiddenColumnOption = HiddenOption.DoNotExport;

            try
            {
                //this.Cursor = Cursors.WaitCursor;

                htmlExporter.RunExport(fileName);

                RadMessageBox.SetThemeName(radGridView.ThemeName);
                DialogResult dr = RadMessageBox.Show("The data in the grid was exported successfully. Do you want to open the file?",
                                                     "Export to HTML", MessageBoxButtons.YesNo, RadMessageIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        System.Diagnostics.Process.Start(fileName);
                    }
                    catch (Exception ex)
                    {
                        string message = String.Format("The file cannot be opened on your system.\nError message: {0}", ex.Message);
                        RadMessageBox.Show(message, "Open File", MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
            }
            catch (IOException ex)
            {
                RadMessageBox.SetThemeName(radGridView.ThemeName);
                //RadMessageBox.Show(this, ex.Message, "I/O Error", MessageBoxButtons.OK, RadMessageIcon.Error);
                System.Windows.Forms.MessageBox.Show(ex.Message, "ERR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //this.Cursor = Cursors.Default;
            }
        }
        private void RunExportToHTML(string fileName, ref bool openExportFile)
        {
            ExportToHTML htmlExporter = new ExportToHTML(this.radGridView1);

            switch (this.radComboBoxSummaries.SelectedIndex)
            {
            case 0:
                htmlExporter.SummariesExportOption = SummariesOption.ExportAll;
                break;

            case 1:
                htmlExporter.SummariesExportOption = SummariesOption.ExportOnlyTop;
                break;

            case 2:
                htmlExporter.SummariesExportOption = SummariesOption.ExportOnlyBottom;
                break;

            case 3:
                htmlExporter.SummariesExportOption = SummariesOption.DoNotExport;
                break;
            }

            //set exporting visual settings
            htmlExporter.ExportVisualSettings = this.exportVisualSettings;
            htmlExporter.TableCaption         = this.radTextBoxSheet.Text;

            try
            {
                htmlExporter.RunExport(fileName);

                RadMessageBox.SetThemeName(this.radGridView1.ThemeName);
                DialogResult dr = RadMessageBox.Show("The data in the grid was exported successfully. Do you want to open the file?",
                                                     "Export to HTML", MessageBoxButtons.YesNo, RadMessageIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    openExportFile = true;
                }
            }
            catch (IOException ex)
            {
                RadMessageBox.SetThemeName(this.radGridView1.ThemeName);
                RadMessageBox.Show(this, ex.Message, "I/O Error", MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }
Пример #4
0
        private void ExportHTMLClick(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = String.Format("{0} (*{1})|*{1}",
                                       "HTML Files",
                                       ".html");
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                ExportToHTML exporter = new ExportToHTML(this.radGridView1);
                exporter.HiddenColumnOption          = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
                exporter.ExportVisualSettings        = true;
                exporter.SummariesExportOption       = SummariesOption.DoNotExport;
                exporter.TableCaption                = "My Table";
                exporter.HTMLTableCaptionFormatting += new
                                                       Telerik.WinControls.UI.Export.HTML.HTMLTableCaptionFormattingEventHandler
                                                           (exporter_HTMLTableCaptionFormatting);
                exporter.RunExport(sfd.FileName);
                MessageBox.Show("Export completed");
            }
        }