private void GenerateReport_Click(object sender, RoutedEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel file (*.xlsx)|*.xlsx"; if (sfd.ShowDialog() == true) { try { DateTime?date = null; if ((DateTime?)SelectDate.SelectedDate == null) { date = DateTime.Now.Date; } else { date = (DateTime?)SelectDate.SelectedDate.Value.Date; } XlsxExport.ExportDailyReport(sfd, date); } catch (Exception ex) { string msg = "Выбранный файл недоступен: " + ex.Message + "/r/nПожалуйста, повторите сохранение, задав другое имя файла."; MessageBoxResult res = MessageBox.Show(msg, "Информация", MessageBoxButton.OK); } } }
private void GenerateReportPeriod_Click(object sender, RoutedEventArgs e) { if (SelectDateFrom.SelectedDate != null && SelectDateTo.SelectedDate != null) { var from = SelectDateFrom.SelectedDate; var to = SelectDateTo.SelectedDate; try { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel file (*.xlsx)|*.xlsx"; if (sfd.ShowDialog() == true) { XlsxExport.ExportDailyReport(sfd, from, to); } } catch (Exception ex) { int point = 0; } } }