...
Diving right into the code
...
Info |
---|
In the Hello World sample |
...
web application, ExcelApplication_HelloWorld.aspx |
...
has a text box for users to supply a value and ExcelApplication_HelloWorld.aspx.cs/vb contains the code shown below. |
1. Include the SoftArtisans.OfficeWriter.ExcelWriter
namespace in the code behind.
...
Vbnet | ||||
---|---|---|---|---|
| ||||
Dim XLAPP As New ExcelApplication() |
Unlike the ExcelTemplate object, which represents a single file, the ExcelApplication
works as a file generation engine. The ExcelApplication
object can be used to create, open, and save multiple workbooks.
3. Create a new workbook with ExcelApplication.Create()
Csharp | ||||
---|---|---|---|---|
| ||||
Workbook WB = XLAPP.Create(ExcelApplication.FileFormat.Excel2007); |
...
Vbnet | ||||
---|---|---|---|---|
| ||||
XLAPP.Save(WB, Page.Response, "Output.xlsx", False) |
ExcelApplication.Save has the same output options as ExcelTemplate
: save to disk, save to memory stream, stream back to the client inline, and stream back to the client as an attachment. In this case, we're streaming the workbook back to the client as an attachment.
Remember that the file extension must match the file format specified when the workbook was created.
7. Go to the web form page, ExcelApplication_HelloWorld.aspx, to try out the sample. Run the code. In the output file, you will see that the custom text from the form has been inserted into cell "A1".
...
Vbnet | ||||
---|---|---|---|---|
| ||||
Include SoftArtisans.OfficeWriter.ExcelWriter |
You can download the Hello World sample code (C# or VB) to see the finished product.
Downloads
You can download the code for the hello world tutorial as a visual studio solution.