Message-ID: <2057723792.8041.1711629798962.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8040_1353623609.1711629798962" ------=_Part_8040_1353623609.1711629798962 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html String Data Source

String Data Source

Intro

Very simple sample that= demonstrates how to use strings of data for an Excel report.


The BindCellData method is used to assign single values to data m= arkers with ExcelTemplate.

To mark where single values on a template would go, place a single objec= t data marker, formatted:%%=3D$variablename.

=20
= =20

Requirements

=20
This sample requires OfficeWriter Enterprise Edition to be installed becau= se the OfficeWriter Grouping and Nesting is only available in the Enterpris= e Edition of the product.=20
=20
=20

Code

=20
public class StringDataSource
    {
        private string recipientName;
        private string recipientCompany;

        /// <summary>
        /// Build the report with ExcelTemplate
        /// </summary>
        public void GenerateReport()
        {

            this.recipientName =3D "Jon Smith";
            this.recipientCompany =3D "SoftArtisans";
            // Create an instance of SoftArtisans ExcelTemplate
            ExcelTemplate xlt =3D new ExcelTemplate();

            // Open the template workbook
                        string templatePath =3D @"..\..\ExcelTemplateF=
iles\StringDataSourceTemplate.xlsx";
            xlt.Open(templatePath);

            // Bind the variables to the template datamarkers
            // %%=3D$RecipientName

            xlt.BindCellData(recipientName, "RecipientName", xlt.=
CreateDataBindingProperties());

            // %%=3D$RecipientCompany
            xlt.BindCellData(recipientCompany, "RecipientCompany"=
, xlt.CreateDataBindingProperties());

            // Process the template to populate it with the Data Source dat=
a
            xlt.Process();

            // Save the report by streaming to the client
            xlt.Save(@"..\..\ExcelOutputFiles\StringDataSource_output.=
xlsx");

        }
    }

=20

Downloads

------=_Part_8040_1353623609.1711629798962--