After setting all options and cell values, the last thing you need to do with your workbook is write it to a file so it can be opened in Microsoft® Excel®. This is easily performed with the Save
method of Workbook
object. You can write the workbook to a stream or have it automatically create an xls file for itself.
Note: Before saving a workbook, it must contain at least one visible worksheet; otherwise, an exception will be thrown when the Save method is called.
The following code shows how to write your workbook to a file once you are done creating it.
In Visual Basic:
workbook.Save("C:Orders.xls")
In C#:
workbook.Save( "C:Orders.xls" );
View on GitHub