Есть следующая выборка:
1. 2017-05-21 13:45:16 Indicator1 15
2. 2017-05-21 13:45:16 Indicator2 13.8
3. 2017-05-21 13:45:16 Indicator3 0
4. 2017-05-21 13:45:16 Indicator4 -7.1
5. 2017-05-21 13:45:16 Indicator5 0
6. 2017-05-21 13:45:16 Indicator6 24.2
7. 2017-05-21 13:45:16 Indicator7 0
8. 2017-05-21 13:45:16 Indicator8 0
9. 2017-05-21 13:45:16 Indicator9 0
10. 2017-05-21 13:45:17 Indicator6 23.2
11. 2017-05-21 13:45:17 Indicator2 14.1
12. 2017-05-21 13:45:18 Indicator4 -6.4
13. 2017-05-21 13:45:18 Indicator6 21.4
14. 2017-05-21 13:45:19 Indicator6 22
15. 2017-05-21 13:45:19 Indicator2 14.2
16. 2017-05-21 13:45:19 Indicator4 -5.9
мне нужно экспортировать в excel эти данные и получить в следующем виде:
Date Time Ind1 Ind2 Ind3 Ind4 Ind5 Ind6 Ind7 Ind8 Ind9
2017-05-21 13:45:16 15 13.8 0 -7.1 0 24.2 0 0 0
2017-05-21 13:45:17 15 14.1 0 -7.1 0 23.2 0 0 0
2017-05-21 13:45:18 15 14.1 0 -6.4 0 21.4 0 0 0
2017-05-21 13:45:19 15 14.2 0 -5.9 0 22 0 0 0
using (SqlDataReader reader = cmd.ExecuteReader())
{
Row newRow = new Row();
while (reader.Read())
{
if (reader[1].ToString() != firstTime)
{
firstTime = reader[1].ToString();
newRow.AppendChild(new Cell { DataType = CellValues.String, CellValue = new CellValue(reader[0].ToString()) });
newRow.AppendChild(new Cell { DataType = CellValues.String, CellValue = new CellValue(firstTime) });
newRow.AppendChild(new Cell { DataType = CellValues.String, CellValue = new CellValue(reader[3].ToString()) });
}
else
{
newRow.AppendChild(new Cell { DataType = CellValues.String, CellValue = new CellValue(reader[3].ToString()) });
}
}sheetData.Append(newRow);
}