Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Covers:

  • 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.

Icon

ExcelWriter templates do not necessarily need to be in the Excel template file format (XLT, XLTX, XLTM), although these formats are supported by ExcelWriter.

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 be DataSource1 or [DataSource1].

Adding data markers to the the template

SOMETHING ABOUT ADDING DATA MARKERS TO THE TEMPLATE FILE
BLAH BLAH SCREEN SHOT

Formatting cells with data markers

BLAH BLAH BLAH NUMBER FORMAT

{{BLAH BLAH BLAH FONT FORMATTING ON CELLS }}

Writing the Code

SOMETHING ABOUT BINDROWDATA and BINDCOLUMN DATA

Icon

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 %%=$DataSourceName.ColumnName, with a $ to denote that the data should be imported as a column instead of a row.

Final Code

Downloads

  • No labels