EPPlusSoftware / EPPlus

EPPlus-Excel spreadsheets for .NET
https://epplussoftware.com
Other
1.73k stars 270 forks source link

Setting HeaderParsingType CamelCaseToSpace within LoadFromCollection no longer working #1513

Open Coeus35 opened 5 days ago

Coeus35 commented 5 days ago

EPPlus usage

Commercial use (I have a commercial license)

Environment

.NET 6.0

Epplus version

7.1.3 - 7.2.1

Spreadsheet application

Excel Tables

Description

When setting HeaderParsingType via LoadFromCollection, it no longer formats HeaderParsingTypes.CamelCaseToSpace correctly

OssianEPPlus commented 3 days ago

We're looking into this issue, thanks for reporting!

OssianEPPlus commented 3 days ago

We are going to need a clearer example of this error and a reproducible code sample. It seems as though it works fine for example if using the following code:

        internal class CamelCasedClass
        {
            public string IdOfThisInstance { get; set; }
        }

        public void ParseCamelCasedHeaders()
        {
            var items = new List<CamelCasedClass>()
            {
                new CamelCasedClass(){ IdOfThisInstance = "123" }
            };
            using (var pck = new ExcelPackage(new MemoryStream()))
            {
                var sheet = pck.Workbook.Worksheets.Add("sheet");
                sheet.Cells["C1"].LoadFromCollection(items, c =>
                {
                    c.PrintHeaders = true;
                    c.HeaderParsingType = HeaderParsingTypes.CamelCaseToSpace;
                });
                Assert.AreEqual("Id Of This Instance", sheet.Cells["C1"].Value);
            }
        }

It seems to parse the the header to space without issue. What type of collection are you using and in what way?

Coeus35 commented 3 days ago

The collection is an IEnumerable of an object model. One difference is that I do have the model decorated with EpplusTableColumn for proper ordering.

[EpplusTable(ShowTotal = true)]
public abstract class BaseBillingReportExportModel
{
    [EpplusTableColumn(Order = 0, TotalsRowLabel = "Totals", NumberFormat = "m/d/yyyy")]
    public DateTime RegistrationDate { get; set; }
    [EpplusTableColumn(Order = 1)]
    public string RegistrantName { get; set; }
}