...
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, |
1.Get the data for the Assets, Losses, and Other datasets
These calls are to a helper method GetCSVData
that parses the CSV files and returns a DataTable
with the values.
If you are following in your own project and would like to parse the CSV files as well, you will need to:
- Add a reference to
GenericParsing.dll
- Include
GeneringParsing
at the top of your code. - Add the
GetCSVData
method that can be found in the sample code.
1.Get the data for the Assets, Losses, and Other datasets
These calls are to a helper method GetCSVData
that parses the CSV files and returns a DataTable
with the values.
Code Block |
---|
DataTable dtAssets = GetCSVData("//data//Assets.csv"); DataTable dtLosses = GetCSVData("//data//Losses.csv"); DataTable dtOther = GetCSVData("//data//Other.csv"); |
...
Code Block |
---|
using SoftArtisans.OfficeWriter.ExcelWriter; using GenericParsing; ... //Instantiate the template object ExcelTemplate XLT = new ExcelTemplate(); //Open the file XLT.Open(Page.MapPath("//templates//Part1_Financial_Template.xlsx")); //Create data binding properties DataBindingProperties bindingProps = XLT.CreateDataBindingProperties(); //Get the data from the CSVs. More info about the generic parser is available //in the project and in the tutorial above. DataTable dtAssets = GetCSVData("//data//Assets.csv"); DataTable dtLosses = GetCSVData("//data//Losses.csv"); DataTable dtOther = GetCSVData("//data//Other.csv"); //Declare the row data. This tutorial uses a single item array to demonstrate the //optional modifier string\[\] headerValues = { "2011" }; string\[\] headerNames = { "FiscalYear" }; //Bind each datatable XLT.BindData(dtAssets, "Assets", bindingProps); XLT.BindData(dtLosses, "Losses", bindingProps); XLT.BindData(dtOther, "Other", bindingProps); //Bind the single row data XLT.BindRowData(headerValues, headerNames, "Header", bindingProps); //Call process to import data to file XLT.Process(); //Save the file XLT.Save(Page.Response, "temp.xlsx", false); |
...