...
Note | ||||
---|---|---|---|---|
| ||||
|
\
Code
...
Code Block |
---|
public class LoanCalculator { //Variables needed for calculations: private double principal = 1000.00d; private double apr = 2.99d; private int numyears = 5; private DateTime date = DateTime.Now; // <summary> // Build the report with ExcelTemplate // </summary> public void GenerateReport() { //Create an instance of ExcelTemplate ExcelTemplate xlt = new ExcelTemplate(); //Open the template workbook string templatePath = @"..\..\ExcelTemplateFiles\LoanCalculatorTemplate.xlsx"; xlt.Open(templatePath); // Pass the data to the BindCellData method // and specify the data source name DataBindingProperties bindingProperties = xlt.CreateDataBindingProperties(); xlt.BindCellData(principal, "Principal", bindingProperties); xlt.BindCellData(apr / 100, "APR", bindingProperties); xlt.BindCellData(numyears, "N", bindingProperties); xlt.BindCellData(date, "Date", bindingProperties); // Call the Process() method to populate the template with the data source values xlt.Process(); // Save the report xlt.Save(@"..\..\ExcelOutputFiles\LoanCalculator_output.xlsx"); } } |
...