...
We're done creating the template. Now it's time to write the code.
Writing the Code
SOMETHING ABOUT BINDROWDATA and BINDCOLUMN DATA
Info |
---|
In the sample code, the a sample web application page |
1. Include the SoftArtisans.OfficeWriter.ExcelWriter namespace in the code behind
Csharp | ||||
---|---|---|---|---|
| ||||
using SoftArtisans.OfficeWriter.ExcelWriter;
|
2. In the method that is going to actually run the report, instantiate the ExcelTemplate object.
Csharp | ||||
---|---|---|---|---|
| ||||
ExcelTemplate XLT = new ExcelTemplate();
|
3. Open the template file from earlier with the ExcelTemplate.Open() method.
Csharp | ||||
---|---|---|---|---|
| ||||
XLT.Open(Page.MapPath("//templates//part1_template.xlsx"));
|
4. Create a DataBindingProperties object. Although we won't be changing any of the binding properties, a DataBindingProperties
is a required parameter in all ExcelTemplate data binding methods.
Csharp | ||||
---|---|---|---|---|
| ||||
DataBindingProperties dataProps = XLT.CreateDataBindingProperties();
|
5.
Info |
---|
If you want to import a row of data as a vertical column in Excel, you need to use ExcelTemplate.BindColumnData and the data marker syntax |
Run your code
Final Code
Csharp | ||||
---|---|---|---|---|
| ||||
Add code here | ||||
Vbnet | 10 | 10 | ||
Add code here |