Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Feb 13, 2020 8:27 pm

Hi,

We are having trouble reading a csv file. I have attached a small sample file that shows the issue. Please run the following code to see the issue:

Code: Select all
            try
            {
                string FilePath = @"20200213_xxxxxxxxxxxNotes.csv";
                IWorkbook Workbook = Factory.GetWorkbook(FilePath);
                IWorksheet Worksheet = Workbook.ActiveWorksheet;
                for (int r = 0; r < 3; r++)
                {
                    for (int c = 0; c < 8; c++)
                    {
                        object obj = Worksheet.Cells[r, c].Value;
                        string Value = (obj != null) ? obj.ToString() : "[null]";
                        System.Diagnostics.Debug.WriteLine($"Row {r} Col {c}: {Value}");
                    }
                }
            }
            catch (Exception Ex)
            {
                System.Diagnostics.Debug.WriteLine(Ex.Message);
            }


The output of the above code is the following:

Code: Select all
Row 0 Col 0: loan_number
Row 0 Col 1: investor_id
Row 0 Col 2: investor_group
Row 0 Col 3: trust_name
Row 0 Col 4: source
Row 0 Col 5: comment_date
Row 0 Col 6: comment_added_by_id
Row 0 Col 7: note
Row 1 Col 0: 1111111111
Row 1 Col 1: 555
Row 1 Col 2: AAA
Row 1 Col 3: RMTP 2019-C2
Row 1 Col 4: COL
Row 1 Col 5: 02/12/2020
Row 1 Col 6: ANI
Row 1 Col 7: 9999999999
Row 2 Col 0: 2222222222
Row 2 Col 1: 555
Row 2 Col 2: BBB
Row 2 Col 3: RMTP 2019-C2
Row 2 Col 4: FOR
Row 2 Col 5: 02/12/2020
Row 2 Col 6: (WS
Row 2 Col 7: [null]


The very last cell contains a string, but the value being returned is null. Are you able to reproduce this problem? Any idea what is causing it?

Thanks.

Tom Ward
Attachments
20200213_xxxxxxxxxxxNotes.rar
(470 Bytes) Downloaded 186 times

tomwardatl@gmail.com
 
Posts: 9
Joined: Mon Jan 07, 2019 7:18 pm

Fri Feb 14, 2020 3:10 am

Hi,

Thanks for your inquiry.
Based on your code, it seemed you didn't use our Spire.XLS.
I have tested your case with Spire.XLS Pack(Hotfix) Version:10.1.8 and following code:
Code: Select all
                string FilePath = @"20200213_xxxxxxxxxxxNotes.csv";
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(FilePath, ",", 1, 1);
                Worksheet Worksheet = workbook.ActiveSheet;
                for (int r = 0; r < 3; r++)
                {
                    for (int c = 0; c < 8; c++)
                    {
                        object obj = Worksheet.Range[r, c].Value;
                        string Value = (obj != null) ? obj.ToString() : "[null]";
                        System.Diagnostics.Debug.WriteLine($"Row {r} Col {c}: {Value}");
                    }
                }

When loading the csv file, there would be an exception "NullReferenceException". I have logged it in our bug tracking system with the ticket SPIREXLS-2118. After fixing the exception, we will check if the last cell is null, then update you.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Feb 24, 2020 5:17 pm

Any update on this bug fix?

tomwardatl@gmail.com
 
Posts: 9
Joined: Mon Jan 07, 2019 7:18 pm

Tue Feb 25, 2020 2:13 am

Hi,

Your issue is under test phase now. Once it passes the test, we will provide the hotfix for you ASAP.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Feb 26, 2020 3:01 pm

Is it possible to tell us what kind of data will cause this error to happen? We need to track down what other files might have had this issue.

Thanks.

Tom Ward

tomwardatl@gmail.com
 
Posts: 9
Joined: Mon Jan 07, 2019 7:18 pm

Thu Feb 27, 2020 2:15 am

Hi Tom,

Thanks for your information.
The reason for your issue is that our internal code has issues. We will let you know once the hotfix is available.
Apologize for the inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Mar 02, 2020 9:52 am

Hi,

Glad to inform you the issue is solved in Spire.XLS Pack(Hotfix) Version:10.3.0.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.XLS/10.3.0
Below code for your kind reference:
Code: Select all
                string FilePath = @"20200213_xxxxxxxxxxxNotes.csv";
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(FilePath, ",", 1, 1);
                Worksheet Worksheet = workbook.ActiveSheet;
                for (int r = 1; r <= 3; r++)
                {
                    for (int c = 1; c <= 8; c++)
                    {
                        object obj = Worksheet.Range[r, c].Value;
                        string Value = (obj != null) ? obj.ToString() : "[null]";
                        System.Diagnostics.Debug.WriteLine($"Row {r} Col {c}: {Value}");
                    }
                }


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Mar 06, 2020 8:08 am

Hi,

Hope you are doing well.
Do you try the hotfix? Has it solved your issue?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS