Exemple #1
0
        //show a message to the user when the background worker has finished
        //and re-enable the export buttons
        private void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            CallCtrlSafety.SetVisible <ProgressBar>(ProgressBar, false, this.ParentForm);

            if (OnEndExport != null)
            {
                OnEndExport(this, new EventArgs());
            }

            if (MessageBox.Show("导出操作完成, 您想打开该Excel文件么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Process.Start(saveFileDialog.FileName);
            }
        }
Exemple #2
0
        /// <summary>
        /// starts the export to new excel document
        /// </summary>
        /// <param name="filepath">the file to export to</param>
        private void StartExport(String filepath)
        {
            if (OnStartExport != null)
            {
                OnStartExport(this, new EventArgs());
            }

            CallCtrlSafety.SetVisible <ProgressBar>(ProgressBar, true, this.ParentForm);

            //create a new background worker, to do the exporting
            BackgroundWorker bg = new BackgroundWorker();

            bg.DoWork             += new DoWorkEventHandler(bg_DoWork);
            bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
            bg.RunWorkerAsync(filepath);

            //create a new export2XLS object, providing DataView as a input parameter
            //export2XLS = new Export2Excel();
            //export2XLS.OnProgressHandler += new Export2Excel.ProgressHandler(export2XLS_prg);
        }
 //Update the progress bar with the a value
 private void export2XLS_prg(object sender, ProgressEventArgs e)
 {
     CallCtrlSafety.SetValue <ProgressBar>(ProgressBar, e.ProgressValue, this.ParentForm);
 }