public static void Export(int exportType, string name, DevExpress.XtraGrid.Views.Grid.GridView gridView) { SaveFileDialog saveFile = new SaveFileDialog(); string title = name + "_export_" + DateTime.Now.ToString("dd_MM_yyyy"); switch (exportType) { case Utilities.EXPORT_EXCEL: title += ".xlsx"; break; case Utilities.EXPORT_PDF: title += ".pdf"; break; } saveFile.FileName = title; if (saveFile.ShowDialog() == DialogResult.OK) { switch (exportType) { case Utilities.EXPORT_EXCEL: gridView.ExportToXlsx(saveFile.FileName); break; case Utilities.EXPORT_PDF: gridView.ExportToPdf(saveFile.FileName); break; } } }
// // HTML 화일변환 // //------------------------------------------------------------------------------------------------------------- private void simplePDF_Click(object sender, EventArgs e) { String fileName = ShowSaveFileDialog("PDF Document", "PDF Documents|*.pdf"); if (fileName != "") { gridView1.ExportToPdf(fileName); OpenFile(fileName); } }
private void btnExport_Click(object sender, EventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view = gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.ExportToPdf("TestExport.pdf"); Process pdfExport = new Process(); pdfExport.StartInfo.FileName = "AcroRd32.exe"; pdfExport.StartInfo.Arguments = "TestExport.pdf"; pdfExport.Start(); } }
private void btnPrintChekedPatient_Click(object sender, EventArgs e) { try { DevExpress.XtraGrid.Views.Grid.GridView view = dataGridView1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.ExportToPdf("بيانات فحص المريض.pdf"); } Process pdfExport = new Process(); pdfExport.StartInfo.FileName = "AcroRd32.exe"; pdfExport.StartInfo.Arguments = "بيانات فحص المريض.pdf"; pdfExport.Start(); } catch (Exception) { } //using ( // SaveFileDialog ofd = new SaveFileDialog() { FileName = "My_Export.xlsx", Filter = "Excel Workbook|*.xlsx", ValidateNames = true } // ) //{ // if (ofd.ShowDialog() == DialogResult.OK) // { // this.Cursor = Cursors.WaitCursor; // string filePath = ofd.FileName; // /// get the sheet page and set it to the dataTable // //BL.ExcelFile excel = new BL.ExcelFile(); // //DataTable theDT = excel.GetSheetTable(excel.currentSheetIndex); // DataTable theDT = new DataTable(); // theDT = (DataTable)dataGridView1.DataSource; // if (theDT == null || theDT.Columns.Count == 0) // theDT = getDataTableFromDataGrid(dataGridView1); // BL.ExcelFile excel = new BL.ExcelFile(); // excel.ExportToExcel(theDT, filePath); // this.Cursor = Cursors.Default; // } //} }
private void simpleButton1_Click(object sender, EventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view = gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { //设置字体 如果不加中文可能会出现乱码 DevExpress.Utils.AppearanceObject.DefaultFont = new System.Drawing.Font("宋体", 9); //PDF的名称 view.ExportToPdf("MainViewData.pdf"); Process pdfExport = new Process(); pdfExport.StartInfo.FileName = "AcroRd32.exe"; pdfExport.StartInfo.Arguments = "MainViewData.pdf"; pdfExport.Start(); } }
private void button1_Click(object sender, EventArgs e) { try { DevExpress.XtraGrid.Views.Grid.GridView view = gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.ExportToPdf("Teacher.pdf"); Process pdf = new Process(); pdf.StartInfo.FileName = "FoxitReader.exe"; pdf.StartInfo.Arguments = "Teacher.pdf"; pdf.Start(); } } catch (Exception a) { MessageBox.Show("Error: " + a); } }
private void btnPrint_Click(object sender, EventArgs e) { try { DevExpress.XtraGrid.Views.Grid.GridView view = dataGridView1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.ExportToPdf("بيانات فحص العدسة.pdf"); } Process pdfExport = new Process(); pdfExport.StartInfo.FileName = "AcroRd32.exe"; pdfExport.StartInfo.Arguments = "بيانات فحص العدسة.pdf"; pdfExport.Start(); } catch (Exception) { } }
private void btnExport_Click(object sender, EventArgs e) { try { DevExpress.XtraGrid.Views.Grid.GridView View = gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (View != null) { View.ExportToPdf("InformationTeacher.pdf"); Process pdfExport = new Process(); pdfExport.StartInfo.FileName = "FoxitReader.exe"; pdfExport.StartInfo.Arguments = "InformationTeacher.pdf"; pdfExport.Start(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public static void ExportPdf(DevExpress.XtraGrid.GridControl grid, string date) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.DefaultExt = "PDF"; saveFileDialog1.FileName = "Exported Data" + date.Replace("/", "_"); saveFileDialog1.Filter = @"PDF (*.pdf) |*.PDF|All files(*.*) |*.*"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.OverwritePrompt = true; saveFileDialog1.Title = "PDF File"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { DevExpress.XtraGrid.Views.Grid.GridView View = grid.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (View != null) { View.OptionsPrint.ExpandAllDetails = true; View.ExportToPdf(saveFileDialog1.FileName); } } }
private void button2_Click(object sender, EventArgs e) { try { DevExpress.XtraGrid.Views.Grid.GridView view = gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.BestFitColumns(); view.OptionsPrint.AutoWidth = false; view.ExportToPdf("Home.pdf"); Process pdf = new Process(); pdf.StartInfo.FileName = "FoxitReader.exe"; pdf.StartInfo.Arguments = "Home.pdf"; pdf.Start(); } } catch (Exception a) { MessageBox.Show("Error: " + a); } }