Export to Excel - LINQ - Include ForeignKey values in .ToList()?

非 Y 不嫁゛ 提交于 2019-11-28 01:40:56

When the current export executes though, instead of getting say AVAILABLE/RECYCLED, the [Status] column in excel contains "InventoryTracker.Models.INV_Statuses" in every cell for each record exported.

That is what you get if System.Object.ToString() is called on an instance of INV_Statuses.

Try overriding ToString() in that class:

public class INV_Statuses
{
    public override string ToString()
    {
        // TODO: Return whatever you would like to have appear in Excel
    }

    // Rest of the class here
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!