Exemplo n.º 1
0
        public void WithCustomConverters()
        {
            DataSetConverter converter = new DataSetConverter();
            DataSourceConverter<DataRow> table1Converter = new DataSourceConverter<DataRow>();
            table1Converter.Fields.Add(new AdapterBoundField<DataRow>("Name", "Character Name"));
            table1Converter.Fields.Add(new AdapterBoundField<DataRow>("Age", "Age", "{0:###}"));
            converter.TableAdapters.Add(table1Converter);
            converter.TableAdapters.Add(DataSetConverter.CreateDefaultDataTableConverter(_data.Tables[1]));
            XlsDocument doc = new XlsDocument();

            converter.CreateDocument(doc, _data);

            Assert.AreEqual(_data.Tables.Count, doc.Workbook.Worksheets.Count);
            DataSourceConverterTest.ValidateWorksheetFromDataTable(doc.Workbook.Worksheets[0], _data.Tables[0]);
            ValidateSheetFromDataTable(doc.Workbook.Worksheets[1], _data.Tables[1]);
        }
Exemplo n.º 2
0
        public void WithCustomConverters()
        {
            DataSetConverter converter = new DataSetConverter();
            DataSourceConverter <DataRow> table1Converter = new DataSourceConverter <DataRow>();

            table1Converter.Fields.Add(new AdapterBoundField <DataRow>("Name", "Character Name"));
            table1Converter.Fields.Add(new AdapterBoundField <DataRow>("Age", "Age", "{0:###}"));
            converter.TableAdapters.Add(table1Converter);
            converter.TableAdapters.Add(DataSetConverter.CreateDefaultDataTableConverter(_data.Tables[1]));
            XlsDocument doc = new XlsDocument();

            converter.CreateDocument(doc, _data);

            Assert.AreEqual(_data.Tables.Count, doc.Workbook.Worksheets.Count);
            DataSourceConverterTest.ValidateWorksheetFromDataTable(doc.Workbook.Worksheets[0], _data.Tables[0]);
            ValidateSheetFromDataTable(doc.Workbook.Worksheets[1], _data.Tables[1]);
        }
Exemplo n.º 3
0
        public void WithDefaultConverters()
        {
            DataSetConverter converter = new DataSetConverter();
            XlsDocument doc = new XlsDocument();

            converter.CreateDocument(doc, _data);

            Assert.AreEqual(_data.Tables.Count, doc.Workbook.Worksheets.Count);

            for (int i = 0; i < doc.Workbook.Worksheets.Count; i++)
            {
                Worksheet worksheet = doc.Workbook.Worksheets[i];
                Assert.AreEqual(_data.Tables[i].TableName, worksheet.Name);

                // validte header row
                ValidateSheetFromDataTable(worksheet, _data.Tables[i]);
            }
        }
Exemplo n.º 4
0
        public void WithDefaultConverters()
        {
            DataSetConverter converter = new DataSetConverter();
            XlsDocument      doc       = new XlsDocument();

            converter.CreateDocument(doc, _data);

            Assert.AreEqual(_data.Tables.Count, doc.Workbook.Worksheets.Count);

            for (int i = 0; i < doc.Workbook.Worksheets.Count; i++)
            {
                Worksheet worksheet = doc.Workbook.Worksheets[i];
                Assert.AreEqual(_data.Tables[i].TableName, worksheet.Name);

                // validte header row
                ValidateSheetFromDataTable(worksheet, _data.Tables[i]);
            }
        }