h2. Intro {excerpt}This guide will explain how to import a multiple rows of values into a PowerPoint presentation using data markers. This assumes a basic understanding of [data markers|How to use Data Markers].{excerpt} || {center} Jump to: {center} || | {toc:minLevel=2|maxLevel=4} | h2. Binding Data PowerPointTemplate has a single method for binding data to the data markers that are located in the template: {{[PowerPointTemplate.BindData]}}. Depending on the data source type and the number of rows in the data source, PowerPointWriter will either import a [single row|Importing a Single Row of Data] of data or import multiple rows by repeating sections of the presentation. By default, every appearance of a data marker will be populated with the same data. For example, if %%=Header.CompanyLogo(image) appears on multiple slides, each data marker will be populated with the company logo. This behavior can be overwritten using [data binding properties|How to Use Data Binding Properties]. When importing multiple row of data, the data marker must be placed in a list entry or table row. The list or table will be expanded to contain all of the imported data. h2. Repeat Slide Behavior h2. DataBindingProperties [Data binding properties|DataBindingProperties] can be used to specify the way data is imported into the presentation. To set the max number of rows to import onto each slide of the presentation use [MaxRowsPerSlide|DataBindingProperties.MaxRowsPerSlide]. MaxRowsPerSlide will continue to import more rows of data as long as it can find a data marker with the 'continue' modifier. For more information see [Fitting Data on to Multiple Slides] h2. Types of Data Sources h4. Arrays of objects Methods: * {{\[PowerPointTemplate.BindData(Object\[\],String\[\],String,DataBindingProperties)\]}} * {{\[PowerPointTemplate.BindData(Object\[\]\[\],String\[\],String,DataBindingProperties)\]}} * {{\[PowerPointTemplate.BindData(Object{}}}{{[,]}}{{,String\[\],String,DataBindingProperties)\]}} Arrays don't have built-in means to store column names. The user must specify the column names in a string array that is passed to {{PowerPointTemplate.BindData}} at run time. PowerPointWriter will import all the rows in a multidimensional array ({{Object\[,\]}}) or a jagged array using built-in repeating behavior. {example} Two dimensional array: {code:csharp|title=C#} string[][] twodim = { new string[]{"Watertown", "MA", "02472"}, new string[]{"Washington", "DC", "20036"} }; string[] names = {"City", "State", "Zip"}; pptt.BindData(twodim, names, "TwoDimArray", pptt.CreateDataBindingProperties()); pptt.Process(); pptt.Save(Page.Response, "ArrayBinding.pptx", false); {code} {code:vbnet|title=vb.net} Dim twodim()() As String = New String()() { _ New String(){"Watertown", "MA", "02472"}, _ New String(){"Washington", "DC", "20036"}, _ } Dim names As String() = {"City", "State", "Zip"} pptt.BindData(twodim, _ names, _ "TwoDimArray", _ pptt.CreateDataBindingProperties()) pptt.Process() pptt.Save(Page.Response, _ "ArrayBinding.pptx", _ False) {code} {example} h4. Data Tables To bind a DataTable to a template data marker call [BindData|PowerPointTemplate.BindData] using the following signature: {newcode} BindData(DataTable dt, String dataMarkerName, DataBindingPeoperties dataProps); {newcode} This signature takes a Datatable, the name of the data marker to which the data source should bind, and a collection [Data Binding Properties|How to Use Data Binding Properties]. protected void (object sender, EventArgs e) { //Create a data table DataTable states = new DataTable(); dt.Columns.Add("State"); dt.Columns.Add("Population"); dt.Rows.Add(new object[] { "Connecticut", "3.6 million residents" }); dt.Rows.Add(new object[] { "Maine", "1.3 million residents" }); dt.Rows.Add(new object[] { "Massachusetts", "6.6 million residents" }); //Create DataBindingProperties DataBindingProperties dataBindProps = pptt.CreateDataBindingProperties(); //Bind the data pptt.BindData(states, "State Info", dataBindProps); } h4. Custom objects {code} |