Problem converting CSV to List with XlsIo from IBrowserFile

I am uploading a CSV file and then converting it to a List with XlsIo in memory. The problem is that the List comes back with the correct amount of records but the record fields are all null, false or 0, depending on the type.

Code:
private void OnInputFileChange(InputFileChangeEventArgs e)
    {
        selectedFile = e.GetMultipleFiles();
        Message = $"{selectedFile.Count} file selected";
        StateHasChanged();
    }

    private async void OnSubmit()
    {
        var file = selectedFile.FirstOrDefault();
        HttpResponseMessage response;

        Stream stream = file.OpenReadStream();
        MemoryStream ms = new MemoryStream();
        await stream.CopyToAsync(ms);
        stream.Close();
        ms.Position = 0;

        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            try
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = excelEngine.Excel.Workbooks.Open(ms, ",");
                IWorksheet worksheet = workbook.Worksheets[0];

                List<Person> people = worksheet.ExportData<Person>(1, 1, 74, 9);
                var count = people.Count();
                response = await Http.PostAsJsonAsync<List<Person>>("api/people/batch", people);
                Message = $"{response}: {selectedFile.Count} file uploaded";
                StateHasChanged();
            }
            catch(Exception e)
            {
                Message = e.Message;
            }

        }
    }

CSV File Excerpt:
"Id","PhotoURI","FirstName","LastName","IsStudent","Gender","BirthDate","DateStarted","DateLastAttended","IsHoh","StudioId","LocationId","hohId","IsProspect","IsVendor","RankId","UniformTopSize","UniformBottomSize","BeltSize"
3,"","Dyana","Ablahad",true,"Female","Jul 1, 1998","Sep 14, 2020","Jan 27, 2021",true,1,1,3,false,false,,,,
4,"2-2AAB6FFE-686C-408B-A5C54ADA7EC5D41E.jpg","Christy","Addison",true,"Female","Jul 3, 1979","Sep 5, 2019","Nov 21, 2020",true,1,1,4,false,false,,,,
5,"3-05B0F0F6-12B8-4EB8-BA01DFBDEE2A6F1E.jpg","Josette","Anderson",true,"Female","Dec 18, 1972","Jul 2, 2019","Jan 26, 2021",true,1,1,5,false,false,,,,
6,"4-F3D30079-F41A-46AC-8AE30AE8FD7900EF.jpg","Luca","Andreola",true,"Male","Feb 22, 2012","Jul 1, 2019","Jan 27, 2021",true,1,1,6,false,false,,,,

2 Replies 1 reply marked as answer

SK Shamini Kiruba Sobers Syncfusion Team February 18, 2021 02:00 PM UTC

Hi Judi, 

Greetings from Syncfusion support. 

We are able to reproduce the scenario and validating it currently. We will share the validation details in two business days on February 22nd, 2021

Regards, 
Shamini 



SK Shamini Kiruba Sobers Syncfusion Team February 22, 2021 07:26 AM UTC

Hi Judi, 

Thanks for the patience. On validating your query with the shared code snippet, we found that its just an usage issue. We have prepared a working sample for your requirement, which can be downloaded from the following link. 


Kindly let us know if the sample helps. 

Regards, 
Shamini 


Marked as answer
Loader.
Up arrow icon