...
Note: At the top of the worksheet, we will display the fiscal year, the company division and group. Below will be 2 tables: one to show the top 5 expenses and another to show all the expenses.
Info | ||
---|---|---|
| ||
In the sample code, the downloadable C# project, there is a completed template file is located in SimpleExpenseSummary/templates/part1_template.xlsx. |
1. Start with a blank .xlsx file. Save the file as template.xlsx.
...
Adding an ExcelWriter Reference in Visual Studio
Info | ||
---|---|---|
| ||
In the sample code, the reference to SoftArtisans.OfficeWriter.ExcelWriter.dll has already been added to the SimpleExpenseSummary project. |
...
- Open Visual Studio and create a .NET project.
- The sample code uses a web application.
- Add a reference to SoftArtisans.OfficeWriter.ExcelWriter.dll
- SoftArtisans.OfficeWriter.ExcelWriter.dll is located under Program Files > SoftArtisans > OfficeWriter > dotnet > bin
Writing the Code
Info | ||
---|---|---|
| ||
There is a sample web application page |
1. Include the SoftArtisans.OfficeWriter.ExcelWriter namespace in the code behind
...
7. Get the data for the Top 5 Expenses and All Expenses data sets.
Info | ||
---|---|---|
| ||
In the sample |
...
project, we |
...
are parsing CSV files |
...
with query results |
...
, rather than querying a live database. The CSV files are available under the data directory. There is a copy of the CSV parser, |
These calls are to a helper method GetCSVData
that parses the CSV files and returns a DataTable
with the values.
Code Block |
---|
DataTable dtTop5 = GetCSVData(Page.MapPath("//data//Part1_Top5Expenses.csv")); DataTable dtAll = GetCSVData(Page.MapPath("//data//Part1_AllExpenses.csv")); |
If you are following in your own project and would like to parse the CSV files as well,
8. Use ExcelTemplate.BindData
to bind the data for the Top 5 Expenses and All Expenses data sets.
...