...
- Single row import (for a header)
- Multi-row import (multiple data sets)
- Note push down
- data markers
- number formatting
- styles on imported data
Setting up the Template
About templates and data markers
An ExcelTemplate template is an Excel file that contains ExcelWriter data markers. A datamarker is a cell value beginning with %%=
that specifies a database colum, variable, or array to insert into the spreadsheet column. Data markers are added to a worksheet in Excel and then bound to data sources in code. ExcelWriter populates the data markers with values from the data sources when the code is executed.
Datamarker syntax
The basic syntax for a datamarker is %%=DataSourceName.ColumnName
, where DataSourceName
is the name of the data source and ColumnName
is the name of the column of data in the data source. You need to follow these rules when naming data markers:
- Names MUST begin with a letter (A-Z, a-z)
- Spaces and Unicode characters are NOT allowed unless the names are inside brackets (
%%=Data Source Name.ColumnName
,%%=DataSourceName.Column$Name
)- The following is a list of characters allowed in data marker names without brackets: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_
- Names must match the names in the data source exactly.
- If a column in a database is 'Street Address', the ColumnName must be
Street Address
to account for the space. Similarly, if a data source name is "DataSource1", the data marker name must beDataSource1
or[DataSource1
.
- If a column in a database is 'Street Address', the ColumnName must be
Info |
---|
ExcelWriter templates do not necessarily need to be in the Excel template file format (XLT, XLTX, XLTM), although these formats are supported by ExcelWriter. |