コード例 #1
0
        public void op_GetEnumerator()
        {
            using (var temp = new TempDirectory())
            {
                var file = temp.Info.ToFile("{0}.xlsx".FormatWith(AlphaDecimal.Random()));
                new DirectoryInfo(Environment.CurrentDirectory).ToFile("Default.xlsx").CopyTo(file.FullName);

                for (var i = 1; i < 4; i++)
                {
                    var sheet = new ExcelDataSheet(file)
                    {
                        Title = "Sheet" + XmlConvert.ToString(i)
                    };
                    Assert.Empty(sheet);
                }
            }
        }
コード例 #2
0
        public void op_GetEnumerator_whenSheet1()
        {
            using (var temp = new TempDirectory())
            {
                var file = temp.Info.ToFile("{0}.xlsx".FormatWith(AlphaDecimal.Random()));
                new DirectoryInfo(Environment.CurrentDirectory).ToFile("Example.xlsx").CopyTo(file.FullName);

                var sheet = new ExcelDataSheet(file)
                {
                    Title = "Sheet1"
                };

                var data = sheet.ToList();
                Assert.Equal(3, data.Count);

                Assert.Equal("Top Left,123,123.45,true", Csv.Line(data[0]));
                Assert.Equal("1969-03-10,456%,£456.78,", Csv.Line(data[1]));
                Assert.Equal("1969-03-10T01:02:03Z,,,false", Csv.Line(data[2]));
            }
        }