У меня есть такой список:
internal class Order
{
public Order()
{
}
public string ProductID { get; set; }
public int Amount { get; set; }
public string Date { get; set; }
}
List<Order> orderList = new List<Order>()
{
new Order(){ ProductID="12345", Amount=300, Date = "2018-12-19"},
new Order(){ ProductID="12345", Amount=0, Date = "2018-12-20"},
new Order(){ ProductID="12345", Amount=200, Date = "2018-12-21"},
new Order(){ ProductID="12345", Amount=250, Date = "2018-12-22"},
new Order(){ ProductID="12345", Amount=30, Date = "2018-12-23"},
new Order(){ ProductID="67898", Amount=20, Date = "2018-12-20"},
new Order(){ ProductID="67898", Amount=30, Date = "2018-12-21"},
new Order(){ ProductID="67898", Amount=40, Date = "2018-12-22"},
new Order(){ ProductID="67898", Amount=50, Date = "2018-12-23"},
new Order(){ ProductID="67898", Amount=130, Date = "2018-12-24"}
};
В этой ситуации, когда я преобразую список в DataTable
и экспортирую его в Excel, я получаю следующее:

Я хочу создать новые столбцы из значений Дата и перечислить их по ProductID .Как я могу преобразовать этот список в DataTable
, чтобы увидеть вот так:
