Esempio n. 1
0
        public void OutputTestWorkbook()
        {
            string html = File.ReadAllText("htmlTable.html");

            WorkbookBuilder workbookBuilder = new WorkbookBuilder();

            workbookBuilder.AddSheet("test", html);

            workbookBuilder.AddSheet("sheet2", html);

            byte[] data = workbookBuilder.GetAsByteArray();

            File.WriteAllBytes(Path.Combine(Environment.CurrentDirectory, "buiilderTest.xlsx"), data);
        }
        public void SpreadSheetHandler_WriteRowsToFile_AddProperties()
        {
            const string sheetName = "sheet1";

            var expected = new Property
            {
                WaxId      = 1,
                Postcode   = "BD13 2AD",
                StreetName = "Bradford Road",
                Address    = "23 Bradford Road",
                Town       = "Gomersal"
            };
            var properties = new List <Property>();

            properties.Add(expected);

            var resultPath = _workbookBuilder
                             .AddSheet(sheetName)
                             .AddPropertyHeaders(sheetName)
                             .CreateWorkbook(_dataFilePath);

            var writeToFile = SpreadSheetHandler.WriteRows(resultPath, sheetName, properties);

            Assert.True(writeToFile);

            var data       = SpreadSheetHandler.ReadRows(resultPath);
            var enumerator = data.GetEnumerator();

            enumerator.MoveNext();
            var actual = enumerator.Current.Value;

            Assert.AreEqual(actual.Postcode, expected.Postcode);
            Assert.AreEqual(actual.Address, expected.Address);
            Assert.AreEqual(actual.WaxId, expected.WaxId);
            Assert.AreEqual(actual.StreetName, expected.StreetName);
            Assert.AreEqual(actual.Town, expected.Town);
        }