Ejemplo n.º 1
0
        private void infoout_Click(object sender, RoutedEventArgs e)
        {
            List <ToolModel> tl = (List <ToolModel>) this.dataGrid1.ItemsSource;

            if (tl == null || tl.Count <= 0)
            {
                return;
            }
            WrenchExcelOut weo            = new WrenchExcelOut();
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            ExcelHelp      _excelHelper   = new ExcelHelp();

            saveFileDialog.Filter = "Excel (*.XLS)|*.xls";
            if ((bool)(saveFileDialog.ShowDialog()))
            {
                try
                {
                    _excelHelper.SaveToExcel(saveFileDialog.FileName, weo.ToTable(tl));
                    MessageBox.Show("导出成功");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("导出失败!");
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        private void bt_dataout_Click(object sender, RoutedEventArgs e)
        {
            List <BorrowHistory> tl = (List <BorrowHistory>) this.gd_borrow.ItemsSource;

            if (tl == null || tl.Count <= 0)
            {
                return;
            }
            SaveFileDialog   saveFileDialog = new SaveFileDialog();
            BorrowOutToExcel uoe            = new BorrowOutToExcel();
            ExcelHelp        _excelHelper   = new ExcelHelp();

            saveFileDialog.Filter = "Excel (*.xls)|*.XLS";
            if ((bool)(saveFileDialog.ShowDialog()))
            {
                try
                {
                    _excelHelper.SaveToExcel(saveFileDialog.FileName, uoe.ToTable(tl));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("导出失败:" + ex.Message);
                    return;
                }
                MessageBox.Show("导出成功");
            }
        }
Ejemplo n.º 3
0
        private void ExportCmdExcute(object param)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Excel (*.XLS)|*.xls";;
            if ((bool)(saveFileDialog.ShowDialog()))
            {
                try
                {
                    _excelHelper.SaveToExcel(saveFileDialog.FileName, _dataGridSource.Table);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("导出失败:" + ex.Message);
                }
                MessageBox.Show("导出成功");
            }
        }