How to change header label when using ExcelEngine ImportData

I have a database table. I read some data using a query and parse it into a list of my dto:
Context.Database.SqlQuery<myDto>(sql);

Next, I want to save this data into an Excel-file using:
ExcelEngine() and worksheet.ImportData(data, 1, 1, true)
This works fine.

But I would like to have slightly different header labels.
I know I can change my Dto and my query to change the headers but I want to keep my current Dto and use some kind of attribute:
Current dto declaration:
public string MessageId { get; set; }
Suggested new dto declaration:
[XlsIO.HeaderLabel = "Message number"]
public string MessageId { get; set; }

Of course, ImportData should look at this attribute and use it when available.
Is this possible? If not can it be added to the feature request list?

I'm using v15.3.0.26

Thanks,

Paul





3 Replies

MC Mohan Chandran Syncfusion Team August 18, 2017 09:54 AM UTC

Hi Paul, 
 
Thank you for contacting Syncfusion support. 
 
Currently, we don’t have a support to get header name from attribute while importing business objects. However, we have logged a feature report and it will be implemented in our upcoming release 2017 Vol 3 SP-1, which is expected to be in the end of August 2017. 
 
Planned Approach: 
We have planned to use DisplayNameAttribute to get header name. So, we request you to change the attribute in your class as shown below.

Expected Code Snippet:
 
[DisplayName("Message number")] 
public string MessageId { get; set; } 
 
Setting such attribute will help you to achieve your requirement. 
 
NOTE: As of now you can change the header text after importing.  

Please let us know if you have any queries.
 
 
Regards,
Mohan



PM Paul Meems August 19, 2017 11:44 AM UTC

Thanks for the reply.

The new sp is right on time. I need this functionality in September.

Looking forward to using this new feature.



SS Sridhar Sukumar Syncfusion Team August 21, 2017 09:18 AM UTC

Hi Paul, 
 
Thank you for updating us. 
 
Please visit our website periodically for release information.  
 
Regards, 
Sridhar. 


Loader.
Up arrow icon