Ejemplo n.º 1
0
        public void ReadTest()
        {
            using (var reader = new ExcelDataReader(@"test.xlsx"))
            {
                reader.Read();
                Assert.AreEqual(381728, reader.GetInt32(0));
                Assert.AreEqual(381728, reader.GetInt64(0));

                Assert.AreEqual("Mr Brown", reader.GetString(1));
                Assert.AreEqual("Mr Brown", reader[1]);
                Assert.AreEqual("Mr Brown", reader["Name"]);

                Assert.AreEqual(new DateTime(1983, 3, 27, 6, 55, 0), reader.GetDateTime(2));

                Assert.AreEqual(new Guid("6E2BF784-F116-494A-916D-9DFF9B2A2AA0"), reader.GetGuid(3));

                Assert.AreEqual(32, reader.GetInt16(4));
                Assert.AreEqual(32, reader.GetInt32(4));
                Assert.AreEqual(32, reader.GetInt64(4));
                Assert.AreEqual(32, reader.GetByte(4));

                Assert.AreEqual(917.68m, reader.GetDecimal(5));
                Assert.AreEqual(917.68d, reader.GetDouble(5));
                Assert.AreEqual(917.68f, reader.GetFloat(5));

                Assert.AreEqual(true, reader.GetBoolean(6));
            }
        }