XLCell.InsertTable and Data Annotations

Mar 10, 2011 at 7:06 PM
Edited Mar 10, 2011 at 7:07 PM

Wow! What a project! Having manually kicked out spreadsheets for some time, I really appreciate what simplicity that ClosedXML brings to the table.

One enhancement I think would be extremely useful and fairly easy to implement would be to modify XLCell.InsertTable so that it honors System.ComponentModel.DataAnnotations display names for table column titles. As it is, I can work around it with some extra code, but it would be great to have declarative control of the friendly names of object columns.

In the event that annotations are in a buddy class, it would be neat to honor those annotations as well.

Below is an example of an annotated class. This idea would have "Due Date" as a table header instead of the space-less "DueDate", and so on.


        class ExportSpreadsheetRow
            [Display(Name = "Type")]
            public string RowType { get; set; }
            public int ID { get; set; }
            [Display(Name = "Name")]
            public string Title { get; set; }
            [Display(Name = "Due Date")]
            public DateTime? DueDate { get; set; }
            [Display(Name = "Completed")]
            public DateTime? CompletedDate { get; set; }
            public string Owner { get; set; }
            public string Comments { get; set; }
Mar 10, 2011 at 7:10 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Mar 10, 2011 at 11:04 PM

I added this feature. The changes will appear on v0.47

Thanks for the feedback.

Mar 12, 2011 at 12:57 AM

Most appreciated. You're doing a fine job!

If I can return the favor and help out in some small way, let me know.