XlsIO Import data from collections - columns/properties order

Hi Syncfusion Team,

I'm using XlsIO to import several List collections into Excel files.

I know it's possible to exclude some properties with the [Bindable(false)] attribute.

But i couldn't find any attribute or something else to set the order for the generated columns.

In my case there is a class like:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace MyNamespace
{
    public class MyClass
    {
        #region Membervariables and properties

        [Display( Order = 1 )]
        public int ID { get; set; }

        [Display( Order = 2 )]
        public string FirstName { get; set; }

        [Display( Order = 3 )]
        public string LastName { get; set; }

        [Display( Order = 7 )]
        public string EmailAddress { get; set; }

        [Display( Order = 8 )]
        public string DateCreated { get; set; }

        #endregion

        #region Extended properties

        [Bindable( false )]
        public Address MainAddress { get; set; }

        #endregion

        #region ReadOnly properties

        [Display( Order = 4 )]
        public string MainAddressStreet
        {
            get
            {
                return this.MainAddress.Street;
            }
        }

        [Display( Order = 5 )]
        public string MainAddressPostCode
        {
            get
            {
                return this.MainAddress.PostCode;
            }
        }

        [Display( Order = 6 )]
        public string MainAddressCity
        {
            get
            {
                return this.MainAddress.City;
            }
        }
        ...

        #endregion

    }
}
which is used for import by:
List<MyClass> dataList = ...;
worksheet.ImportData( dataList, ... );
and it would be great if the generated columns in the Excel file would have been the same order as set in the Order property of the Display attributes and not in the order of their occurence in the class.

Best Regards,
Stefan Falz

3 Replies

SK Shamini Kiruba Sobers Syncfusion Team March 29, 2021 12:54 PM UTC

Hi Stefan, 

Greetings from Syncfusion support. 

Currently we don’t have support for ordering the columns in the Excel file based on the values in the Order property of the DisplayAttribute and having no immediate plans to implement this. 

Regards, 
Shamini 



SI Sivanesan September 12, 2022 05:53 AM UTC

Hi Syncfusion Support Team,

I have this same requirement of ordering the data columns, in a specific order.

Any update on the implementation of this feature?

If not implemented yet, Could you prioritize this feature?


Regards,

Sivanesan.S



RS Ramya Sivakumar Syncfusion Team September 13, 2022 03:32 PM UTC

Hi Sivanesan,


We have logged a feature report as Support for ordering the columns in the Excel based on the values in the Order property but do not have any immediate plans to implement this feature in near future. You can track the status of the feature report through the following feedback link.


Track Status: https://www.syncfusion.com/feedback/37698/support-for-ordering-the-columns-in-the-excel-file-based-on-the-values-in-the


As for now we suggest using the Template marker to order the columns in the Excel. We have prepared the sample for the template marker. kindly try this and let us know if the solution helps.


Sample link -https://www.syncfusion.com/downloads/support/directtrac/general/ze/XlsIO_Sample763589769


Kindly review the following link to know more about the Template marker

https://help.syncfusion.com/file-formats/xlsio/working-with-template-markers


Regards,

Ramya


Loader.
Up arrow icon