private void ExportEXCEL_Click(object sender, RoutedEventArgs e) { try { var options = new Syncfusion.UI.Xaml.Grid.Converter.ExcelExportingOptions(); options.ExcelVersion = ExcelVersion.Excel2013; var excelEngine = dataGridConsulta.ExportToExcel(dataGridConsulta.View, options); var workBook = excelEngine.Excel.Workbooks[0]; SaveFileDialog sfd = new SaveFileDialog { FilterIndex = 2, Filter = "Excel 97 to 2003 Files(*.xls)|*.xls|Excel 2007 to 2010 Files(*.xlsx)|*.xlsx|Excel 2013 File(*.xlsx)|*.xlsx" }; if (sfd.ShowDialog() == true) { using (Stream stream = sfd.OpenFile()) { if (sfd.FilterIndex == 1) { workBook.Version = ExcelVersion.Excel97to2003; } else if (sfd.FilterIndex == 2) { workBook.Version = ExcelVersion.Excel2010; } else { workBook.Version = ExcelVersion.Excel2013; } workBook.SaveAs(stream); } //Message box confirmation to view the created workbook. if (MessageBox.Show("Usted quiere abrir el archivo en excel?", "Ver archvo", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer] System.Diagnostics.Process.Start(sfd.FileName); } } } catch (Exception w) { SiaWin.Func.SiaExeptionGobal(w); MessageBox.Show("error al exportar"); } }
private void Export_excel(object sender, RoutedEventArgs e) { var options = new Syncfusion.UI.Xaml.Grid.Converter.ExcelExportingOptions(); options.ExcelVersion = ExcelVersion.Excel2013; var excelEngine = dataGridCxC.ExportToExcel(dataGridCxC.View, options); var workBook = excelEngine.Excel.Workbooks[0]; SaveFileDialog sfd = new SaveFileDialog { FilterIndex = 2, Filter = "Excel 97 to 2003 Files(*.xls)|*.xls|Excel 2007 to 2010 Files(*.xlsx)|*.xlsx|Excel 2013 File(*.xlsx)|*.xlsx" }; if (sfd.ShowDialog() == true) { using (Stream stream = sfd.OpenFile()) { if (sfd.FilterIndex == 1) { workBook.Version = ExcelVersion.Excel97to2003; } else if (sfd.FilterIndex == 2) { workBook.Version = ExcelVersion.Excel2010; } else { workBook.Version = ExcelVersion.Excel2013; } workBook.SaveAs(stream); } if (MessageBox.Show("Usted quiere abrir el archivo en excel?", "Ver archvo", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { System.Diagnostics.Process.Start(sfd.FileName); } } }
private void ExportaXLS_Click(object sender, RoutedEventArgs e) { try { var options = new Syncfusion.UI.Xaml.Grid.Converter.ExcelExportingOptions(); options.ExcelVersion = ExcelVersion.Excel2013; //options.ExcludeColumns.Add("idreg"); //options.ExcludeColumns.Add("cod_trn"); //options.ExcludeColumns.Add("nom_trn"); //options.ExcludeColumns.Add("num_trn"); //options.ExcludeColumns.Add("fec_trn"); //options.ExcludeColumns.Add("bod_tra"); //options.ExcludeColumns.Add("ent_uni"); //options.ExcludeColumns.Add("ent_cost"); //options.ExcludeColumns.Add("ent_ctotal"); //options.ExcludeColumns.Add("sal_uni"); //options.ExcludeColumns.Add("sal_cost"); //options.ExcludeColumns.Add("sal_ctotal"); //options.ExcludeColumns.Add("saldo_uni"); //options.ExcludeColumns.Add("saldo_cost"); //options.ExcludeColumns.Add("saldo_ctotal"); var excelEngine = GridKardex.ExportToExcel(GridKardex.View, options); var workBook = excelEngine.Excel.Workbooks[0]; SaveFileDialog sfd = new SaveFileDialog { FilterIndex = 2, Filter = "Excel 97 to 2003 Files(*.xls)|*.xls|Excel 2007 to 2010 Files(*.xlsx)|*.xlsx|Excel 2013 File(*.xlsx)|*.xlsx" }; if (sfd.ShowDialog() == true) { using (Stream stream = sfd.OpenFile()) { if (sfd.FilterIndex == 1) { workBook.Version = ExcelVersion.Excel97to2003; } else if (sfd.FilterIndex == 2) { workBook.Version = ExcelVersion.Excel2010; } else { workBook.Version = ExcelVersion.Excel2013; } workBook.SaveAs(stream); } //Message box confirmation to view the created workbook. if (MessageBox.Show("Usted quiere abrir el archivo en excel?", "Ver archvo", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer] System.Diagnostics.Process.Start(sfd.FileName); } } } catch (Exception w) { MessageBox.Show("error al exportar:" + w); } }