Search code examples
c#excelautomationexport-to-excel

Excel Automation: Open existing Excel file as "new"


I want to have a "one-click" excel export feature for my application. I therefore need to create an excel file in a temporary location, because I need to use a third-party component to do so.

I want Excel to then open up the file. I can get to that point; however Excel always remembers the location it loaded the file from. I'd like the loaded file to appear as a "new" file which is not saved to a specific location, so when the user wants to hit "save" (not save as) or close Excel it reminds them of unsaved changes.

I'm using Excel Automation from C# on .net 3.5


Solution

  • You can specify any existing Excel workbook as the template. Then you use the Workbooks.Add method to open a new workbook, with the Template parameter pointing to the temporary template.