0

Some tips about my project:

-ASP.NET MVC 5.2.7 -Entity Framework 6.4 (Database First) -EPPlus 4

Requirements:

-Develop a simple and clean way to send IEnumerables from querys to Excel.

The solution:

-EPPlus and LoadFromCollection function.

The problem:

-Column headers in Excel keep same text as DB column names, and user don't like that.

-I set attribute DisplayName to set headers text, it seems it´s the only valid attribute for this matter.

-As I've configured my EF model Database first, if I set attributes to model, they're erased when model is updated.

-Then I tried metadata solution to set attributes to EF models, works great for validation. But for DisplayName, Visual Studio throws this error in compilation: Attribute 'DisplayName' is not valid on this declaration type. It is only valid on 'class, method, property, indexer, event' declarations.

I've tried to find a solution but I couldn't. Maybe it's something so simple anyone needed to ask before, although I don't know how to achieve that, may anyone help me?

How can I customize column headers text using LoadFromCollection and EF in DB First configuration?

Thanks in advance!

  • Have you gone through the examples at https://github.com/EPPlusSoftware/EPPlus.Sample.NetFramework/blob/master/01-GettingStarted/GettingStartedSample.cs ? – intrixius May 20 '20 at 11:41
  • No, thanks. I've just checked. It seems the problem is in "metadata solution". Because if I apply DisplayName or Description attributes directly in the model, it works. But if I apply attributes on metadatatype class, it doesn't work. Anyway, I've picked some ideas from the examples. Thank you very much for your help. – Fox Mulder May 20 '20 at 12:39

0 Answers0