private void PrepareData()
        {
            _aLogBookForm = new FrmExcel
                (
                true,
                new PrintDgv())
                            {
                                TopMost = true,
                                StartPosition = FormStartPosition.CenterScreen
                            };

            _aLogBookForm.Show();
        }
Example #2
0
        private void ExportToExcel(DataTable calendarData)
        {
            if (calendarData != null)
            {
                var aprintdialog = new PrintDgv();
                try
                {
                    string currentLocation = AppDomain.CurrentDomain.BaseDirectory + "LogFileExports\\";
                    Directory.CreateDirectory(currentLocation);
                    string aFileLocation = DataTableToExcel.MyDataTableExtensions.ExportToExcel
                        (
                            calendarData,
                            currentLocation);

                    try
                    {
                        var afrmExcel = new FrmExcel();

                        afrmExcel.ctrlExcel1.RetrieveWorkbook
                            (
                                aFileLocation,
                                aprintdialog);
                        afrmExcel.Show();
                    }
                    catch (Exception e)
                    {
                        MessageDialog.Show
                            (
                                "ExportToExcel: Excel file could not be Opened!\n",
                                e.Message,
                                MessageDialog.MessageBoxButtons.Ok,
                                MessageDialog.MessageBoxIcon.Error,
                                e.Message + "\r\n\r\n" + e.StackTrace
                            );
                    }
                }
                catch (Exception e)
                {
                    MessageDialog.Show
                        (
                            "ExportToExcel: Excel file could not be Opened!\n",
                            e.Message,
                            MessageDialog.MessageBoxButtons.Ok,
                            MessageDialog.MessageBoxIcon.Error,
                            e.StackTrace
                        );
                }
            }
        }
 private void GetSetFileType(
     string extension,
     string selectedFilePath)
 {
     if (!IsImageFile.IsRecognisedImageFile(selectedFilePath))
     {
         FrmExcel aFrmExcel;
         FrmWord aFrmWord;
         switch (extension)
         {
             case "xlsx":
                 aFrmExcel = new FrmExcel(selectedFilePath);
                 aFrmExcel.Show();
                 break;
             case "xla":
                 aFrmExcel = new FrmExcel(selectedFilePath);
                 aFrmExcel.Show();
                 break;
             case "xls":
                 aFrmExcel = new FrmExcel(selectedFilePath);
                 aFrmExcel.Show();
                 break;
             case "xlam":
                 aFrmExcel = new FrmExcel(selectedFilePath);
                 aFrmExcel.Show();
                 break;
             case "doc":
                 aFrmWord = new FrmWord(selectedFilePath);
                 aFrmWord.Show();
                 break;
             case "docx":
                 aFrmWord = new FrmWord(selectedFilePath);
                 aFrmWord.Show();
                 break;
             case "txt":
                 aFrmWord = new FrmWord(selectedFilePath);
                 aFrmWord.Show();
                 break;
             case "rtf":
                 aFrmWord = new FrmWord(selectedFilePath);
                 aFrmWord.Show();
                 break;
         }
     }
     else
     {
         var aPricture = new FrmPricture(selectedFilePath);
         aPricture.Show();
     }
 }