public void OneTimeSetUp()
        {
            var origDom = new HtmlDom(roundtripTestBook, true);

            _roundtrippedDom = new HtmlDom(roundtripTestBook, true);             //Will get imported into

            // We want to test that exporting a book with branding in the data-dive and importing into a book with no branding
            // does not reinstate the branding. So we need to remove it from the pre-import DOM, which is otherwise
            // (for this test) the same as what we originally exported.
            var branding =
                _roundtrippedDom.SelectSingleNode("//div[@data-book='outside-back-cover-branding-bottom-html']");

            branding.ParentNode.RemoveChild(branding);
            AssertThatXmlIn.Dom(origDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@id='simpleFormattingTest']", 1);
            AssertThatXmlIn.Dom(origDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@id='nestedFormattingTest']", 1);
            var mockLangDisplayNameResolver = new Mock <ILanguageDisplayNameResolver>();

            mockLangDisplayNameResolver.Setup(x => x.GetLanguageDisplayName("en")).Returns("English");
            var exporter = new SpreadsheetExporter(mockLangDisplayNameResolver.Object);

            exporter.Params  = new SpreadsheetExportParams();
            _sheetFromExport = exporter.Export(origDom, "fakeImagesFolderpath");
            using (var tempFile = TempFile.WithExtension("xslx"))
            {
                _sheetFromExport.WriteToFile(tempFile.Path);
                var sheet    = InternalSpreadsheet.ReadFromFile(tempFile.Path);
                var importer = new SpreadsheetImporter(null, _roundtrippedDom);
                importer.Import(sheet);
            }
        }
Example #2
0
        public void OneTimeSetUp()
        {
            var dom = new HtmlDom(kSimpleTwoPageBook, true);

            _exporter        = new SpreadsheetExporter();
            _sheetFromExport = _exporter.Export(dom);
            _rowsFromExport  = _sheetFromExport.ContentRows.ToList();
            using (var tempFile = TempFile.WithExtension("xslx"))
            {
                _sheetFromExport.WriteToFile(tempFile.Path);
                _sheetFromFile = InternalSpreadsheet.ReadFromFile(tempFile.Path);
                _rowsFromFile  = _sheetFromFile.ContentRows.ToList();
            }
        }
Example #3
0
 public void RichtextNotUsedWhenNotNeeded()
 {
     using (var tempFile = TempFile.WithExtension("xslx"))
     {
         _sheetFromExport.WriteToFile(tempFile.Path);
         var info = new FileInfo(tempFile.Path);
         using (var package = new ExcelPackage(info))
         {
             var worksheet = package.Workbook.Worksheets[0];
             int c         = _sheetFromExport.StandardLeadingColumns.Length;
             for (int r = 0; r < 4; r++)
             {
                 ExcelRange currentCell = worksheet.Cells[r + 1, c + 1];
                 Assert.That(!currentCell.IsRichText);
             }
         }
     }
 }
Example #4
0
        public void OneTimeSetUp()
        {
            var dom = new HtmlDom(kSimpleTwoPageBook, true);
            var langCodesToLangNames = new Dictionary <string, string>();

            langCodesToLangNames.Add("en", "English");
            langCodesToLangNames.Add("fr", "French");
            langCodesToLangNames.Add("de", "German");
            var mockLangDisplayNameResolver = new Mock <ILanguageDisplayNameResolver>();

            mockLangDisplayNameResolver.Setup(x => x.GetLanguageDisplayName("en")).Returns("English");
            mockLangDisplayNameResolver.Setup(x => x.GetLanguageDisplayName("fr")).Returns("French");
            mockLangDisplayNameResolver.Setup(x => x.GetLanguageDisplayName("de")).Returns("German");
            _exporter        = new SpreadsheetExporter(mockLangDisplayNameResolver.Object);
            _sheetFromExport = _exporter.Export(dom, "fakeImagesFolderpath");
            _rowsFromExport  = _sheetFromExport.ContentRows.ToList();
            using (var tempFile = TempFile.WithExtension("xslx"))
            {
                _sheetFromExport.WriteToFile(tempFile.Path);
                _sheetFromFile = InternalSpreadsheet.ReadFromFile(tempFile.Path);
                _rowsFromFile  = _sheetFromFile.ContentRows.ToList();
            }
        }