Exemplo n.º 1
0
        public void TestExcelImportStream()
        {
            string filename = PathToTestData + "testReading.xlsx";

            // display error messages in english
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

            using (MemoryStream ms = new MemoryStream())
            {
                using (FileStream fs = File.OpenRead(filename))
                {
                    fs.CopyTo(ms);
                }

                DataTable table = TCsv2Xml.ParseExcelStream2DataTable(ms, true);

                Assert.AreEqual("test1", table.Columns[0].ColumnName, "name of first column");
                Assert.AreEqual("1", table.Rows[0][0].ToString(), "value of first row, first column");
                Assert.AreEqual("2", table.Rows[0]["test2"].ToString(), "value of first row, second column");
                Assert.AreEqual("vier", table.Rows[0][3].ToString(), "value of first row, forth column");
            }
        }