fingers10 / ExcelExport

Classes to generate Excel/CSV Report in ASP.NET Core
MIT License
49 stars 22 forks source link

Discriminate properties to include them or not in the Excel report #2

Closed rogerospina closed 4 years ago

rogerospina commented 4 years ago

Hi Abdul, I added an improvement to discriminate if a property must be included in the report or not. Can I contribute it in your Github project?

fingers10 commented 4 years ago

Hey @rogerospina thanks for writing. You are always welcome to contribute.

By the way what do you mean by including or excluding a property? Can you describe more about this use case? Because the simple way to exclude a property is to not have it in the Final Excel Model. Excel Model is specific to excel creation and not advised to use for any other purpose/use. Please can you write more about this idea? I would be happy to hear.

Thanks, Abdul

rogerospina commented 4 years ago

Hi @fingers10 thanks to you for your excellent and helpfull development.

This is what I mean: In my case I have a view (printed in a table) with pagination, filters and other stuff. According to this View, I made the option to Export (with yours classes) the default view or current applied filter to an excel file.

My class ViewModel is the same for the table (what is showed in screen) and for the Excel file. For some reasons not all properties are showed, however they have some special tasks, depending each of them. So I didn't want to make another class ViewModel only for the Excel file, because I'd be duplicating code and I couldn't delete any property either.

So this is my idea → I created a custom attribute class for properties, to explicitly set if a property should be include in the Excel file or not. And if this attribute doesn't set, it'd be ok, the default value would be "true".

Something like this →

[IncludeInReport(false)] public int? UserId { get; set; }

What do you think ?

Thanks

fingers10 commented 4 years ago

feel free to submit your idea as PR. I'll review and merge

rogerospina commented 4 years ago

Hi @fingers10 I can't submit any changes, or create a branch, I don't have permissions to do it. Or what do you mean "as PR"?

fingers10 commented 4 years ago

@rogerospina PR means Pull Request. Follow the below steps.

  1. Fork my repository.
  2. Now you will have a copy of this repo on your account.
  3. Do your changes and commit in that copy.
  4. Then submit a pull request.

A little bit of googling should help you.

fingers10 commented 4 years ago

I have merged your PR. Many Thanks @rogerospina .