public static void ExportExcelProcess(RadGridView _gv) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { string strFileName = saveFileDialog1.FileName; ExportToExcelML exporter = new ExportToExcelML(_gv);//RadGridView1) string fileName = strFileName; exporter.RunExport(fileName); } }
private void ExportExcel_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = String.Format("{0} (*{1})|*{1}", "Excel Files", ".xls"); if (sfd.ShowDialog() == DialogResult.OK) { //Create instance of the exporter. ExportToExcelML exporter = new ExportToExcelML(this.radGridView1); exporter.FileExtension = "xls"; exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport; exporter.ExportVisualSettings = true; exporter.SummariesExportOption = SummariesOption.DoNotExport; exporter.SheetMaxRows = ExcelMaxRows._1048576; exporter.SheetName = "Sheet"; exporter.ExcelCellFormatting += new Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventHandler(exporter_ExcelCellFormatting); exporter.ExcelTableCreated += new Telerik.WinControls.UI.Export.ExcelML.ExcelTableCreatedEventHandler(exporter_ExcelTableCreated); exporter.RunExport(sfd.FileName); MessageBox.Show("Export completed"); } }
private void radButtonElement1_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "*.xls|*.xls"; saveFileDialog1.FileName = "export"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { radGridView1.Columns[6].ExcelExportType = DisplayFormatType.Text; radGridView1.Columns[7].ExcelExportType = DisplayFormatType.Text; radGridView1.Columns[2].ExcelExportType = DisplayFormatType.Custom; radGridView1.Columns[2].ExcelExportFormatString = "dd.MM.yyyy"; if (radGridView1.Columns["Выезд"] != null) { radGridView1.Columns["Выезд"].ExcelExportType = DisplayFormatType.Custom; radGridView1.Columns["Выезд"].ExcelExportFormatString = "dd.MM.yyyy"; } if (radGridView1.Columns["Смерть"] != null) { radGridView1.Columns["Смерть"].ExcelExportType = DisplayFormatType.Custom; radGridView1.Columns["Смерть"].ExcelExportFormatString = "dd.MM.yyyy"; } if (radGridView1.Columns["Дата над. обсл."] != null) { radGridView1.Columns["Дата над. обсл."].ExcelExportType = DisplayFormatType.Custom; radGridView1.Columns["Дата над. обсл."].ExcelExportFormatString = "dd.MM.yyyy"; } ExportToExcelML exporter = new ExportToExcelML(radGridView1); exporter.PagingExportOption = PagingExportOption.AllPages; exporter.RunExport(saveFileDialog1.FileName); System.Diagnostics.Process.Start(saveFileDialog1.FileName); } }
private void printTheScheduleButton_Click(object sender, EventArgs e) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.InitialDirectory = @"c:\"; saveDialog.Filter = "Excell File (*.xls)|*.xls"; saveDialog.FilterIndex = 2; saveDialog.RestoreDirectory = true; string filePath = ""; if (saveDialog.ShowDialog() == DialogResult.OK) { filePath = saveDialog.FileName.ToString(); ExportToExcelML exporter = new ExportToExcelML( (documentTabStrip1.TabPanels[documentTabStrip1.SelectedIndex].Controls[0] as TimetableGridview).gridviewSchedule); exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport; exporter.ExportVisualSettings = true; exporter.SheetName = "Разписание за " + documentTabStrip1.TabPanels[0].Text.ToString(); exporter.ExcelCellFormatting += exporter_ExcelCellFormatting; exporter.RunExport(filePath); } //PrintTheScheduleForm printSchedule = new PrintTheScheduleForm(mDBManager); //printSchedule.Show(); }
void radButtonExport_Click(object sender, EventArgs e) { if (radGridData.RowCount != 0) { SaveFileDialog saveFileDialog = new SaveFileDialog(); ExportToExcelML excelExporter = null; try { ExportToExcelML excelML = new ExportToExcelML(this.radGridData); excelExporter = new ExportToExcelML(this.radGridData); excelExporter.ExcelCellFormatting += excelExporter_ExcelCellFormatting; excelExporter.ExcelTableCreated += exporter_ExcelTableCreated; this.Cursor = Cursors.WaitCursor; saveFileDialog.Filter = "Excel (*.xls)|*.xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { excelExporter.RunExport(saveFileDialog.FileName); DialogResult dr = RadMessageBox.Show("การบันทึกไฟล์สำเร็จ คุณต้องการเปิดไฟล์หรือไม่?", "Export to Excel", MessageBoxButtons.YesNo, RadMessageIcon.Question); if (dr == DialogResult.Yes) { System.Diagnostics.Process.Start(saveFileDialog.FileName); } } } catch (Exception) { } } else { RadMessageBox.Show("ไม่มีข้อมูล"); return; } }
void Btn_ExportToExcel_Click(object sender, EventArgs e) { if (this.rgv_ReportDLHR.Visible == true) { if (rgv_ReportDLHR.RowCount != 0) { SaveFileDialog saveFileDialog = new SaveFileDialog(); ExportToExcelML excelExporter = null; try { ExportToExcelML excelML = new ExportToExcelML(this.rgv_ReportDLHR); excelExporter = new ExportToExcelML(this.rgv_ReportDLHR); excelExporter.ExcelCellFormatting += excelExporter_ExcelCellFormatting; excelExporter.ExcelTableCreated += exporter_ExcelTableCreated; this.Cursor = Cursors.WaitCursor; saveFileDialog.Filter = "Excel (*.xls)|*.xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { excelExporter.RunExport(saveFileDialog.FileName); DialogResult dr = RadMessageBox.Show("การบันทึกไฟล์สำเร็จ คุณต้องการเปิดไฟล์หรือไม่?", "Export to Excel", MessageBoxButtons.YesNo, RadMessageIcon.Question); if (dr == DialogResult.Yes) { System.Diagnostics.Process.Start(saveFileDialog.FileName); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { if (con.State == ConnectionState.Open) con.Close(); } } else { RadMessageBox.Show("ไม่มีข้อมูล"); return; } } else if (this.rgv_ReportDSHR.Visible == true) { if (rgv_ReportDSHR.RowCount != 0) { SaveFileDialog saveFileDialog = new SaveFileDialog(); ExportToExcelML excelExporter = null; try { ExportToExcelML excelML = new ExportToExcelML(this.rgv_ReportDSHR); excelExporter = new ExportToExcelML(this.rgv_ReportDSHR); excelExporter.ExcelCellFormatting += excelExporter_ExcelCellFormatting; excelExporter.ExcelTableCreated += exporter_ExcelTableCreated; this.Cursor = Cursors.WaitCursor; saveFileDialog.Filter = "Excel (*.xls)|*.xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { excelExporter.RunExport(saveFileDialog.FileName); DialogResult dr = RadMessageBox.Show("การบันทึกไฟล์สำเร็จ คุณต้องการเปิดไฟล์หรือไม่?", "Export to Excel", MessageBoxButtons.YesNo, RadMessageIcon.Question); if (dr == DialogResult.Yes) { System.Diagnostics.Process.Start(saveFileDialog.FileName); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { if (con.State == ConnectionState.Open) con.Close(); } } else { RadMessageBox.Show("ไม่มีข้อมูล"); return; } } else if (this.rgv_ReportCHDHR.Visible == true) { if (rgv_ReportCHDHR.RowCount != 0) { SaveFileDialog saveFileDialog = new SaveFileDialog(); ExportToExcelML excelExporter = null; try { ExportToExcelML excelML = new ExportToExcelML(this.rgv_ReportCHDHR); excelExporter = new ExportToExcelML(this.rgv_ReportCHDHR); excelExporter.ExcelCellFormatting += excelExporter_ExcelCellFormatting; excelExporter.ExcelTableCreated += exporter_ExcelTableCreated; this.Cursor = Cursors.WaitCursor; saveFileDialog.Filter = "Excel (*.xls)|*.xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { excelExporter.RunExport(saveFileDialog.FileName); DialogResult dr = RadMessageBox.Show("การบันทึกไฟล์สำเร็จ คุณต้องการเปิดไฟล์หรือไม่?", "Export to Excel", MessageBoxButtons.YesNo, RadMessageIcon.Question); if (dr == DialogResult.Yes) { System.Diagnostics.Process.Start(saveFileDialog.FileName); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { if (con.State == ConnectionState.Open) con.Close(); } } else { RadMessageBox.Show("ไม่มีข้อมูล"); return; } } }
void RunExportToExcelML(string fileName, ref bool openExportFile) { ExportToExcelML excelExporter = new ExportToExcelML(this.radGridReport); excelExporter.SheetName = string.Format(@"MNRP{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), DateTime.Now.Millisecond); //excelExporter.SheetMaxRows = ExcelMaxRows._1048576; //ExcelMaxRows._65536 //set exporting visual settings excelExporter.ExportVisualSettings = true; //if (this.radTextBoxSheet.Text != String.Empty) //{ // excelExporter.SheetName = this.radTextBoxSheet.Text; //} //switch (this.radComboBoxSummaries.SelectedIndex) //{ // case 0: // excelExporter.SummariesExportOption = SummariesOption.ExportAll; // break; // case 1: // excelExporter.SummariesExportOption = SummariesOption.ExportOnlyTop; // break; // case 2: // excelExporter.SummariesExportOption = SummariesOption.ExportOnlyBottom; // break; // case 3: // excelExporter.SummariesExportOption = SummariesOption.DoNotExport; // break; //} //set max sheet rows //if (this.radRadioButton1.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) //{ // excelExporter.SheetMaxRows = ExcelMaxRows._1048576; //} //else if (this.radRadioButton2.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) //{ // excelExporter.SheetMaxRows = ExcelMaxRows._65536; //} //set exporting visual settings //excelExporter.ExportVisualSettings = this.exportVisualSettings; try { excelExporter.RunExport(fileName); RadMessageBox.SetThemeName(this.radGridReport.ThemeName); DialogResult dr = RadMessageBox.Show("The data in the grid was exported successfully. Do you want to open the file?", "Export to Excel", MessageBoxButtons.OK, RadMessageIcon.Question); if (dr == DialogResult.Yes) { openExportFile = true; } } catch (IOException ex) { RadMessageBox.SetThemeName(this.radGridReport.ThemeName); RadMessageBox.Show(this, ex.Message, "Info", MessageBoxButtons.OK, RadMessageIcon.Error); } }
void RunExportToExcelML(string fileName, ref bool openExportFile) { ExportToExcelML excelExporter = new ExportToExcelML(this.radGridTimeTemp); excelExporter.SheetName = string.Format(@"MNRPSRC{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), DateTime.Now.Millisecond); excelExporter.ExportVisualSettings = true; try { excelExporter.RunExport(fileName); RadMessageBox.SetThemeName(this.radGridTimeTemp.ThemeName); RadMessageBox.Show("The data in the grid was exported successfully.", "Export to Excel", MessageBoxButtons.OK, RadMessageIcon.Info); } catch (IOException ex) { RadMessageBox.SetThemeName(this.radGridTimeTemp.ThemeName); RadMessageBox.Show(this, ex.Message, "Info", MessageBoxButtons.OK, RadMessageIcon.Error); } }
private void exportButton_Click(object sender, EventArgs e) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.InitialDirectory = @"c:\"; saveDialog.Filter = "Excell File (*.xls)|*.xls"; saveDialog.FilterIndex = 2; saveDialog.RestoreDirectory = true; string filePath = ""; if (saveDialog.ShowDialog() == DialogResult.OK) { try { filePath = saveDialog.FileName.ToString(); ExportToExcelML exporter = new ExportToExcelML(this.gridviewSchedule); exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport; exporter.ExportVisualSettings = true; exporter.SheetName = "Разписание за " + dropdownListClasses.SelectedItem.Text; exporter.ExcelCellFormatting += exporter_ExcelCellFormatting; exporter.RunExport(filePath); } catch { } } }