private void button1_Click(object sender, EventArgs e) { PivotGridControl pivot = pivotGridControl1; if (pivot.Cells.Selection.IsEmpty) { pivotGridControl1.ExportToXlsx(fileName); } else { Rectangle selection = pivot.Cells.Selection; Point fCell = pivot.Cells.FocusedCell; pivot.Tag = selection; pivot.CustomFieldValueCells += pivotGridControl1_CustomFieldValueCells; try { pivot.RefreshData(); pivot.ExportToXlsx(fileName); } finally { pivot.CustomFieldValueCells -= pivotGridControl1_CustomFieldValueCells; pivot.RefreshData(); pivot.Cells.FocusedCell = fCell; pivot.Cells.Selection = selection; } } System.Diagnostics.Process.Start(fileName); }
private void PivotSaveToXlsxDataAwareMenuItem_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Excel File (*.xlsx)|*.Xlsx|All files (*.*)|*.*"; dialog.FilterIndex = 0; dialog.DefaultExt = "Xlsx"; dialog.AddExtension = true; DevExpress.XtraPrinting.XlsxExportOptionsEx options = new DevExpress.XtraPrinting.XlsxExportOptionsEx(); options.ExportType = DevExpress.Export.ExportType.DataAware; if (dialog.ShowDialog() == DialogResult.OK) { pivotGrid.ExportToXlsx(dialog.FileName, options); } }
public static void ExportTo(this PivotGridControl pvtGrid, string fileName, bool openAfterExport = false) { var ext = new FileInfo(fileName).Extension; switch (ext) { case ".csv": pvtGrid.ExportToCsv(fileName); break; case ".htm": case ".html": pvtGrid.ExportToHtml(fileName); break; case ".bmp": pvtGrid.ExportToImage(fileName); break; case ".mht": pvtGrid.ExportToMht(fileName); break; case ".pdf": pvtGrid.ExportToPdf(fileName); break; case ".rtf": pvtGrid.ExportToRtf(fileName); break; case ".txt": pvtGrid.ExportToText(fileName); break; case ".xls": pvtGrid.ExportToXls(fileName); break; case ".xlsx": pvtGrid.ExportToXlsx(fileName); break; default: throw new Exception("გთხოვთ აირჩიოთ სწორი ფაილის ტიპი."); } if (openAfterExport) { try { Process.Start(fileName); } catch { //if (throwError) throw; } } }
public static void ExportarExel(PivotGridControl GrdGrilla) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Title = "Buscar Ruta"; dlg.Filter = "Todos Los Archivos Xlsx | *.xlsx"; if (dlg.ShowDialog() == DialogResult.OK) { GrdGrilla.ExportToXlsx(dlg.FileName); } }
/// <summary> /// ExportToExcel /// </summary> /// <param name="pivotGridControl"></param> public static void ExportToExcel(this PivotGridControl pivotGridControl) { SaveFileDialog saveDlg = new SaveFileDialog(); saveDlg.InitialDirectory = "c:\\"; saveDlg.Filter = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*"; saveDlg.RestoreDirectory = true; if (saveDlg.ShowDialog() == DialogResult.OK) { var pivotExportOptions = new DevExpress.XtraPivotGrid.PivotXlsxExportOptions(); pivotExportOptions.ExportType = DevExpress.Export.ExportType.DataAware; pivotGridControl.ExportToXlsx(saveDlg.FileName, pivotExportOptions); } }
public static string ExportToExcel(PivotGridControl pivot, TextExportMode exportMode) { try { var fileName = GetSaveExcelFileName(); var extension = Path.GetExtension(fileName); if (extension == ".xls") { pivot.ExportToXls(fileName, new XlsExportOptions( exportMode, true)); } else if (extension == ".xlsx") { pivot.ExportToXlsx(fileName, new XlsxExportOptions( exportMode, true)); } else { return ""; } return fileName; } catch { } return ""; }
public static void ExportExcell(this PivotGridControl pivot) { try { string filename = string.Empty; string value = string.Empty; if (InputBox("Fayl", "Faylın adını daxil edin:", ref value) == DialogResult.OK) { filename = value; } else { return; } if (filename.Trim().Length == 0) { return; } FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Qovluq seçin"; if (fbd.ShowDialog() == DialogResult.OK) { //SetFileNameFrm sfnfrm = new SetFileNameFrm(); //sfnfrm.ShowDialog(); if (fbd.SelectedPath != string.Empty) { filename = fbd.SelectedPath + "\\" + filename + ".xlsx"; if (!File.Exists(filename)) { if (pivot != null) { DevExpress.XtraPrinting.XlsxExportOptionsEx o = new DevExpress.XtraPrinting.XlsxExportOptionsEx(); o.AllowCellMerge = DevExpress.Utils.DefaultBoolean.False; o.AllowGrouping = DevExpress.Utils.DefaultBoolean.False; o.ApplyFormattingToEntireColumn = DevExpress.Utils.DefaultBoolean.False; o.GroupState = DevExpress.Export.GroupState.Default; o.RawDataMode = false; pivot.ExportToXlsx(filename, o); } DialogResult dr = XtraMessageBox.Show("Faylı indi açmaq istəyirsinizmi?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { if (File.Exists(filename)) { System.Diagnostics.Process.Start(filename); } } else { dr = DialogResult.No; } } else { XtraMessageBox.Show("Fayl seçdiyiniz qovluqda mövcuddur"); } } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }