hodzung / excellibrary

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

create Workbook from DataSet with Guid #116

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a DataTable/DataSet have a Guid column
2. Use DataSetHelper to create WorkBook
3. throw exception "Invalid Cell Value"

My solution is convert value to string if value is Guid or any strange type 
data.

Fix it:
1. Open WorkSheetEncoder.cs
2. Find "private static CellValue EncodeCell(Cell cell, SharedResource 
sharedResource)" function
3. In the Else part, select and delete Else block, replace with this block

You can see in my attached cs file.
(Note: Sorry I don't know how to make a patch file)
================================================================================
======
            else if (value is Guid)
            {
                LABELSST label = new LABELSST();
                label.SSTIndex = sharedResource.GetSSTIndex(value.ToString());
                return label;
            }
            else
            {
                try
                {
                    LABELSST label = new LABELSST();
                    label.SSTIndex = sharedResource.GetSSTIndex(value.ToString());
                    return label;
                }
                catch
                {
                    string type = value.GetType().FullName;
                    throw new Exception("Invalid cell value: type = " + type);
                }
            }
================================================================================
======

Original issue reported on code.google.com by luckymon...@gmail.com on 24 Nov 2011 at 7:04

Attachments: