I need to write data to an excel sheet and need to open it after writing it. This is the code I am using..
object misValue = System.Reflection.Missing.Value;
Excel.Application xlAppEnv = new Excel.ApplicationClass();
Excel.Workbook xlForEnv = xlAppEnv.Workbooks.Add(misValue);
Excel.Worksheet xlForEnv_View = (Excel.Worksheet)xlForEnv.Worksheets.get_Item(1);
xlForEnv_View.Name = "PF Keys";
xlForEnv_View.Cells[row, column] = "data";
I could write data using the above code and when I am done, I could save the file to a predefined location using the below code..
envSaveLoc = envSaveLoc + "\\PF Keys.xlsx";
xlForEnv.SaveAs(envSaveLoc, Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlAppEnv.DisplayAlerts = true;
xlForEnv.Close(true, misValue, misValue);
xlAppEnv.Quit();
The above code is working fine but now the requirement is that the program shouldn't save it but once the data is written to the excel sheet, open the file in excel and present to the user. User can then review and save it himself by using File->Save as option. How can I achieve it? The data can be stored in some temporary location for presenting to the user.