We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change header label when using ExcelEngine ImportData

Thread ID:

Created:

Updated:

Platform:

Replies:

132160 Aug 17,2017 11:49 AM UTC Aug 21,2017 09:18 AM UTC ASP.NET Web Forms 3
loading
Tags: XlsIO
Paul Meems
Asked On August 17, 2017 11:49 AM UTC

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





Mohan Chandran [Syncfusion]
Replied On 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


Paul Meems
Replied On 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.


Sridhar Sukumar [Syncfusion]
Replied On August 21, 2017 09:18 AM UTC

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;