I'm trying to find a way to have the excel file automatically open as soon as it is done downloading. The file is called "ExportAging.xlsx" and the closest I've gotten to the solution is this:
This is the code I have
private void ExportToExcel()
{
try
{
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.Filter = "Excel files (*.xlsx)|*.xlsx";
saveDialog.FilterIndex = 1;
saveDialog.FileName = "ExportAging";
if (saveDialog.ShowDialog() == DialogResult.OK)
{
workbook.SaveAs(saveDialog.FileName);
saveDialog.OpenFile();
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
excel.Quit();
workbook = null;
excel = null;
}
}
Any help is appreciated.