Ejemplo n.º 1
0
        public void ExcelGenerator_LoadDataTable()
        {
            string data =
                @"<Data>
  <Table1>
    <Record id='1' name='Наименование 1' count='100' date='2017-04-30T22:10:38'/>
    <Record id='2' name='Наименование 2' count='200' date='2017-05-01'/>
  </Table1 >
</Data>";
            XDocument xmlData = XDocument.Parse(data);

            ExcelGenerator.ColumnMapping[] columnMappings =
            {
                new ExcelGenerator.ColumnMapping("@id",    "ID",           "System.Int32"),
                new ExcelGenerator.ColumnMapping("@name",  "Наименование", "System.String"),
                new ExcelGenerator.ColumnMapping("@count", "Кол-во",       "System.Int32"),
                new ExcelGenerator.ColumnMapping("@date",  "Дата/время",   "System.DateTime"),
            };

            DataTable table = ExcelGenerator.LoadDataTable(xmlData, "Table1", columnMappings);

            Assert.IsNotNull(table);
        }