public void GetHtmlTableNode_HtmlWithNoTables_ShouldThrowException() { string htmlWithTable = "<div></div>"; HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlWithTable); try { HtmlNode node = new HtmlAgilityUtilities().GetHtmlTableNode(htmlDoc); } catch (Exception ex) { StringAssert.Contains(ex.Message, HtmlAgilityUtilities.NoTableNodesFoundMessage); } }
public void AddBackgroundToCellNode() { var htmlWithTable = "<div><table><thead></thead><tbody><tr><td style=\"background-color: #bbbbbb;\">Test</td></tr></tbody></table></div>"; HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlWithTable); HtmlNode node = new HtmlAgilityUtilities().GetHtmlTableNode(htmlDoc); var package = new ExcelPackage(); new EPPlusUtilities(new HtmlToExcelSettings()).CreateSheet(package, SheetName, node); var sheet = package.Workbook.Worksheets[SheetName]; var cell = sheet.Cells.First(); if (cell.Style.Fill.BackgroundColor.Rgb != "01BBBBBB") { Assert.Fail("The first cell is not filled."); } }
public void GetHtmlTableNode_HtmlWithSingleTable_ShouldReturnTableHtmlNode() { string htmlWithTable = "<div><table><thead></thead><tbody></tbody></table></div>"; HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlWithTable); HtmlNode node = new HtmlAgilityUtilities().GetHtmlTableNode(htmlDoc); Assert.IsTrue(node != null && node.Name == "table"); if (node == null) { Assert.Fail("The HtmlNode was null"); } if (node.Name != "table") { Assert.Fail("The HtmlNode was not a table"); } }