You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
I'm currently trying to export some DataTable data to excel. One of the columns in my table is of type List<string>. I first create a DataTableReader and then try to load the data into a worksheet using LoadFromDataReader like so:
public static ToReader(List<object> data)
{
var toReturn = new DataTable();
// Complex code about creating the data table
return new DataTableReader(toReturn);
}
//...
public static Export(List<object> data)
{
using (var pck = new ExcelPackage())
{
// add the content into the Excel file
ExcelWorksheet ws = pck.Workbook.Worksheets["Data"];
ws.Cells[startCell].LoadFromDataReader(ToReader(data), true);
//....
}
}
All the data gets exported to excel just fine except for the column which contains List<string>. For this column I would expect the cell value to be comma separated values of that list, instead I just get the first element of the list.
E.g. if the list was {"Fee", "Fi", "Fo", "Fum"}, I would expect the cell value to be "Fee, Fi, Fo, Fum", instead I get "Fee".
From debugging I see that data is correctly written to the DataTableReader, so the problem must be with loading it into excel.
From SO answers it seems that the culprit is this part of EPPlus code.
Is this an issue with EPPlus or for some reason this is desired behavior?
I couldn't find the issue mentioned in the EPPlus code.
The text was updated successfully, but these errors were encountered:
mdmilic
changed the title
columns with collection
Exporting DataTable with columns whose type is a collection
Dec 17, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm currently trying to export some
DataTable
data to excel. One of the columns in my table is of typeList<string>
. I first create aDataTableReader
and then try to load the data into a worksheet usingLoadFromDataReader
like so:All the data gets exported to excel just fine except for the column which contains
List<string>
. For this column I would expect the cell value to be comma separated values of that list, instead I just get the first element of the list.E.g. if the list was {"Fee", "Fi", "Fo", "Fum"}, I would expect the cell value to be "Fee, Fi, Fo, Fum", instead I get "Fee".
From debugging I see that data is correctly written to the DataTableReader, so the problem must be with loading it into excel.
From SO answers it seems that the culprit is this part of EPPlus code.
Is this an issue with EPPlus or for some reason this is desired behavior?
I couldn't find the issue mentioned in the EPPlus code.
The text was updated successfully, but these errors were encountered: