private void btnExport_Click(object sender, EventArgs e) { //VietBaIT.LABLink.Reports.ExcelReport.ExportGridEx(grdPatient); Stream sw = null; try { var sd = new SaveFileDialog {Filter = "Excel File (*.xls)|*.xls|All Files (*.*)|*.*"}; if (sd.ShowDialog() == DialogResult.OK) { //sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); sw = new FileStream(sd.FileName, FileMode.Create); var grdListExporter = new GridEXExporter(); grdListExporter.IncludeExcelProcessingInstruction = true; grdListExporter.IncludeFormatStyle = true; grdListExporter.IncludeHeaders = true; grdListExporter.GridEX = grdPatient; grdListExporter.Export(sw); Utility.ShowMsg("Xuất dữ liệu thành công"); } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally { if (sw != null) { sw.Flush(); sw.Close(); sw.Dispose(); } } }
public static void ExportGridEx(Janus.Windows.GridEX.GridEX gridEx ) { Stream sw = null; try { var sd = new SaveFileDialog { Filter = "Excel File (*.xml)|*.xml" }; if (sd.ShowDialog() == DialogResult.OK) { //sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); sw = new FileStream(sd.FileName, FileMode.Create); GridEXExporter grdListExporter = new GridEXExporter(); grdListExporter.IncludeExcelProcessingInstruction = true; grdListExporter.IncludeFormatStyle = true; grdListExporter.IncludeHeaders = true; grdListExporter.GridEX = gridEx; grdListExporter.Export(sw); Utility.ShowMsg("Xuất dữ liệu thành công"); } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally { if (sw != null) { sw.Flush(); sw.Close(); sw.Dispose(); } } }
protected void CreateXLSFile(string XLSFileName, GridEX gridEX, ExportMode exportMode) { try { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Excel files (*.xls)|*.xls"; saveFileDialog1.InitialDirectory = Application.StartupPath + "\\Excels"; saveFileDialog1.FileName = XLSFileName; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; DialogResult dr = saveFileDialog1.ShowDialog(); if (dr == DialogResult.Cancel) { return; } if (File.Exists(saveFileDialog1.FileName)) { File.Delete(saveFileDialog1.FileName); } GridEXExporter gridEXExporter1 = new GridEXExporter(); gridEXExporter1.GridEX = gridEX; gridEXExporter1.ExportMode = exportMode; gridEXExporter1.Export(saveFileDialog1.OpenFile()); Process process1 = new Process(); process1.StartInfo.FileName = saveFileDialog1.FileName; process1.Start(); } catch (Exception exp) { EMessage.Show("خطا در ایجاد فایل اکسل\r\n" + exp.Message, "خطا در ایجاد فایل اکسل", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnExport_Click(object sender, EventArgs e) { //VietBaIT.LABLink.Reports.ExcelReport.ExportGridEx(grdPatient); Stream sw = null; try { var sd = new SaveFileDialog { Filter = "Excel File (*.xls)|*.xls|All Files (*.*)|*.*" }; if (sd.ShowDialog() == DialogResult.OK) { //sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); sw = new FileStream(sd.FileName, FileMode.Create); var grdListExporter = new GridEXExporter(); grdListExporter.IncludeExcelProcessingInstruction = true; grdListExporter.IncludeFormatStyle = true; grdListExporter.IncludeHeaders = true; grdListExporter.GridEX = grdPatient; grdListExporter.Export(sw); Utility.ShowMsg("Xuất dữ liệu thành công"); } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally { if (sw != null) { sw.Flush(); sw.Close(); sw.Dispose(); } } }
public static void ExportGridEx(GridEX gridEx) { Stream streamWrite = null; try { var saveDialog = new SaveFileDialog { Filter = "Xml File (*.xml)|*.xml|All Files (*.*)|*.*" }; if (saveDialog.ShowDialog() == DialogResult.OK) { streamWrite = new FileStream(saveDialog.FileName, FileMode.Create); var gridExporter = new GridEXExporter(); gridExporter.IncludeExcelProcessingInstruction = true; gridExporter.IncludeFormatStyle = true; gridExporter.IncludeHeaders = true; gridExporter.GridEX = gridEx; gridExporter.Export(streamWrite); MessageBox.Show("Eksport danych do pliku został zakończony.", "Eksport do pliku", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { } finally { if (streamWrite != null) { streamWrite.Flush(); streamWrite.Close(); streamWrite.Dispose(); } } }
public static void ExportGridEx(GridEX gridEx, string name) { Stream sw = null; try { var sd = new SaveFileDialog { Filter = @"Excel File (*.xls)|*.xls|All Files (*.*)|*.*" }; if (sd.ShowDialog() == DialogResult.OK) { //sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); sw = new FileStream(sd.FileName, FileMode.Create); var grdListExporter = new GridEXExporter(); grdListExporter.SheetName = name; grdListExporter.IncludeExcelProcessingInstruction = true; grdListExporter.IncludeFormatStyle = true; grdListExporter.IncludeHeaders = true; grdListExporter.GridEX = gridEx; grdListExporter.Export(sw); MessageBox.Show(@"تهیه فایل با موفقیت انجام شد"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (sw != null) { sw.Flush(); sw.Close(); sw.Dispose(); } } }
public static void ExportGridEx(Janus.Windows.GridEX.GridEX gridEx) { Stream sw = null; try { var sd = new SaveFileDialog { Filter = "Excel File (*.xml)|*.xml" }; if (sd.ShowDialog() == DialogResult.OK) { //sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); sw = new FileStream(sd.FileName, FileMode.Create); GridEXExporter grdListExporter = new GridEXExporter(); grdListExporter.IncludeExcelProcessingInstruction = true; grdListExporter.IncludeFormatStyle = true; grdListExporter.IncludeHeaders = true; grdListExporter.GridEX = gridEx; grdListExporter.Export(sw); Utility.ShowMsg("Xuất dữ liệu thành công"); } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } finally { if (sw != null) { sw.Flush(); sw.Close(); sw.Dispose(); } } }