Message-ID: <358873118.9657.1711697980440.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9656_867345622.1711697980440" ------=_Part_9656_867345622.1711697980440 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Chart Report

Chart Report

Intro

Any chart that references a = range with data markers will have its data source updated when ExcelTemplat= e imports rows of data. Make changes to a template without making any chang= es to code.

Open the template, right click on the chart and choose the "Select = Data..." option.  This will open a window with details about the = charts data range.  Though the range for the chart is only one row (= =3DChartSheet!$A$26:$B$26), will update the data formula when the data is b= ound to the data markers in the cells.   

A populated version of the chart is available for download below.

Code

=20
public void GenerateReport()
        {
            // Creat=
e an instance of ExcelTemplate
            ExcelTem=
plate xlt =3D new ExcelTemplate();
 
            // Open =
the template workbook
            string t=
emplatePath =3D @"..\..\ExcelTemplateFiles\ChartDemoTemplate.xlsx"=
;;
            xlt.Open=
(templatePath);
 
            DataTabl=
e dt =3D GetCSVData(@"..\..\ExcelData\ChartDemoData.csv");
 
            // Pass =
the DataTable to ExcelTemplate
            xlt.Bind=
Data(dt, "SalesData", xlt.CreateDataBindingProperties());
            // Call =
the process() method to populate the
            // templ=
ate with the data source values and save
            // the p=
opulated document
            xlt.Proc=
ess();
            xlt.Save=
(@"..\..\ExcelOutputFiles\ChartDemo_output.xlsx");
 
        }
 
        /// <summary>
        /// Reads the CSV and returns da=
tatable
        /// </summary>
        /// <returns>DataTable of =
top 5 products</returns>
        System.Data.DataTable GetCSVData=
(string csvFileName)
        {
            DataTabl=
e dt;
            using (G=
enericParserAdapter parser =3D new GenericParserAdapter(csvFileName))
            {
            &nb=
sp;   parser.ColumnDelimiter =3D ',';
            &nb=
sp;   parser.FirstRowHasHeader =3D true;
 
            &nb=
sp;   dt =3D parser.GetDataTable();
            }
            return d=
t;
        }
    }
 
 
=20

Downloads

------=_Part_9656_867345622.1711697980440--