hodzung / excellibrary

Automatically exported from code.google.com/p/excellibrary
1 stars 0 forks source link

Valid Cell value check in class WorkSheetEncoder #65

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a new cell with value System.DBNull.Value
2.Save Workbook

What is the expected output? What do you see instead?
Expected output is to treat this value the same as null. Instead an exception 
"Invalid cell value." is thrown.

What version of the product are you using? On what operating system?
20090331. Windows server 2003.

Please provide any additional information below.
I corrected this with changing line #62 from:
if (cell != Cell.EmptyCell && cell.Value != null)

to:
if (cell != Cell.EmptyCell && cell.Value != null && cell.Value != 
System.DBNull.Value)

Original issue reported on code.google.com by halliday...@gmail.com on 17 Aug 2010 at 12:05

GoogleCodeExporter commented 9 years ago
Where I can found latest dll with the fix of this issue ?

Original comment by deepjyot...@gmail.com on 12 Jul 2012 at 2:26

GoogleCodeExporter commented 9 years ago
The private static CellValue EncodeCell(Cell cell, SharedResource 
sharedResource) function in worksheetencoder.cs file did not provide a solution 
to handle dbNull value when importing from datagridview controls or datatables. 
I added the following snippet to write out a "no value" string to the cell when 
dbnull is encountered.

 // ADDED: to fix dbnull reference. 
            else if (value is System.DBNull)
            {
                LABELSST label = new LABELSST();
                label.SSTIndex = sharedResource.GetSSTIndex("NO VALUE");
                return label;

            }
// not the best solution but it worked in my situation.

Original comment by phil.s.c...@gmail.com on 9 Jun 2013 at 5:18