IMailMergeDataSource equivalent for Cells

In Aspose.Words we have used an implementation of IMailMergeDataSource. I was wondering if there was an interface I could use with WorkpointDesigner.SetDataSource that would work like that interface. The IMailMergeDataSource is really good for being able to get only the values for fields when their value is requested by the document. It appears to work where the Merge will ask the DataSource if it has that value during the merge.

It looks like WorkpointDesigner.SetDataSource and Process don’t work that way. The SetDataSource appears to convert that supplied object into a ICellsDataTable that is populated based on what is in the the dataset at that time. So all columns have to be defined and populated before passing the value to SetDataSource.

Am I missing functionality that exits in Aspose.Cells? Have you given thought to making Aspose.Cells have an equivalent API as Aspose.Words? WorkbookDesigner appears functionally equivalent to a Word Mail Merge but DataSources function differently.

@mike.doerfler,
Please spare us little time as we are analysing this requirement and will share our feedback soon.

@mike.doerfler,
We have logged the issue in our database for investigations. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46927 - IMailMergeDataSource equivalent for Cells

@mike.doerfler,
Please try the latest fix 19.9.2 with the attached file.

SmartMarker1.zip (6.1 KB)

1: Please simply set the custom object list as the data source.

        CustomerList customers = new CustomerList();

        customers.Add(new Customer("Thomas Hardy", "120 Hanover Sq., London"));

        customers.Add(new Customer("Paolo Accorti", "Via Monte Bianco 34, Torino"));



        Workbook wb = new Workbook(Constants.sourcePath + "CellsNet46927.xlsx");

        WorkbookDesigner designer = new WorkbookDesigner(wb);



         designer.SetDataSource("Customer", customers);

       designer.Process();

        wb.Save(Constants.destPath + "dest.xlsx");

2: Implement the ICellsDataTable as the following :

public void CellsNet46927()

    {

        CustomerList customers = new CustomerList();

        customers.Add(new Customer("Thomas Hardy", "120 Hanover Sq., London"));

        customers.Add(new Customer("Paolo Accorti", "Via Monte Bianco 34, Torino"));

        Workbook wb = new Workbook(Constants.sourcePath + "CellsNet46927.xlsx");

        WorkbookDesigner designer = new WorkbookDesigner(wb);

        //  designer.SetDataSource("Customer", customers);

        designer.SetDataSource("Customer", new CustomerDataSource(customers));

        designer.Process();

        wb.Save(Constants.destPath + "dest.xlsx");

    }

    public class CustomerDataSource : ICellsDataTable

    {



        public CustomerDataSource(CustomerList customers)

        {



            this.m_DataSource = customers;

            this.m_Properties = customers[0].GetType().GetProperties();

            this.m_Columns = new string[this.m_Properties.Length];

            this.m_PropHash = new Hashtable(this.m_Properties.Length);



            for (int i = 0; i < m_Properties.Length; i++)

            {

                this.m_Columns[i] = m_Properties[i].Name;

                this.m_PropHash.Add(m_Properties[i].Name, m_Properties[i]);

            }

            this.m_IEnumerator = this.m_DataSource.GetEnumerator();

        }



        internal string[] m_Columns;

        internal ICollection m_DataSource;

        private Hashtable m_PropHash;

        private IEnumerator m_IEnumerator;

        private System.Reflection.PropertyInfo[] m_Properties;





        public string[] Columns

        {

            get

            {

                return this.m_Columns;

            }

        }

        public int Count

        {

            get

            {

                return this.m_DataSource.Count;

            }

        }

        public void BeforeFirst()

        {

            this.m_IEnumerator = this.m_DataSource.GetEnumerator();



        }

        public object this[int index]

        {

            get

            {

                return this.m_Properties[index].GetValue(this.m_IEnumerator.Current, null);

            }

        }

        public object this[string columnName]

        {

            get

            {

                return ((System.Reflection.PropertyInfo)this.m_PropHash[columnName]).GetValue(this.m_IEnumerator.Current, null);

            }

        }



        public bool Next()

        {

            if (this.m_IEnumerator == null)

                return false;

            return this.m_IEnumerator.MoveNext();

        }

    }



    /// <summary>

    /// An example of a "data entity" class in your application.

    /// </summary>

    public class Customer

    {

        public Customer(string aFullName, string anAddress)

        {

            FullName = aFullName;

            Address = anAddress;

        }



        public string FullName { get; set; }

        public string Address { get; set; }

    }



    /// <summary>

    /// An example of a typed collection that contains your "data" objects.

    /// </summary>

    public class CustomerList : ArrayList

    {

        public new Customer this[int index]

        {

            get { return (Customer)base[index]; }

            set { base[index] = value; }

        }

    }

Aspose.Cells19.9.2 For .Net2_AuthenticodeSigned.Zip (4.9 MB)
Aspose.Cells19.9.2 For .Net4.0.Zip (5.0 MB)

The issues you have found earlier (filed as CELLSNET-46927) have been fixed in Aspose.Cells for .NET v19.10. This message was posted using Bugs notification tool by Amjad_Sahi