Is there a way to implement a progress bar on the Workbook.Save(filestream) method?
Thanks,
MarkGoolara, LLC
If your .Save call is done on a background thread you would be able to update the UI (a progress bar).
As an example:
private void Button_Click(object sender, RoutedEventArgs e) { BackgroundWorker bw = new BackgroundWorker(); bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged); bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.WorkerReportsProgress = true; bw.RunWorkerAsync(); } void bw_DoWork(object sender, DoWorkEventArgs e) { Workbook wb = new Workbook(); BackgroundWorker bw = (BackgroundWorker)sender; Worksheet workSheet = wb.Worksheets.Add("WS1") ; for (int i = 0; i < 65000; i++) {
workSheet.Rows[i].Cells[0].Value = i; int progress = (int)((i / 65000.0) * 100); bw.ReportProgress(progress); System.Threading.Thread.Sleep(1); } }
void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) { this.progBar.Value = e.ProgressPercentage; }
I would like to know this as well if anyone can help.
Thanks!