public void BuildsXmlParagraphs() { ExcelRange thirdCell = _worksheet.Cells[3, 3]; string xmlString = SpreadsheetIO.BuildXmlString(thirdCell); Assert.That(xmlString, Is.EqualTo("<p></p><p><strong>Apples</strong></p><p><strong>Bananas</strong></p><p><em>Cherries</em></p><p></p><p><em>Durian</em></p>")); }
public void BuildsXmlSimple() { ExcelRange firstCell = _worksheet.Cells[1, 1]; string xmlString = SpreadsheetIO.BuildXmlString(firstCell); Assert.That(xmlString, Is.EqualTo("<p>nnn<u>uuu</u>nnn<sup>sss</sup><em>iii</em><strong>bbb</strong></p>")); }
public void SpreadsheetIOWriteSpreadsheet_RetainMarkupOptionRetainsMarkup() { using (var tempFile = TempFile.WithExtension("xslx")) { SpreadsheetIO.WriteSpreadsheet(_sheetFromExport, tempFile.Path, retainMarkup: true); var info = new FileInfo(tempFile.Path); using (var package = new ExcelPackage(info)) { var worksheet = package.Workbook.Worksheets[0]; int c = _sheetFromExport.GetRequiredColumnForLang("en"); var rowCount = worksheet.Dimension.Rows; //The first TextGroup row should contain the marked-up string we are looking for for (int r = 0; true; r++) { Assert.That(r, Is.LessThan(rowCount), "did not find expected TextGroup row"); ExcelRange rowTypeCell = worksheet.Cells[r + 1, 1]; if (rowTypeCell.Value.ToString().Equals(InternalSpreadsheet.PageContentRowLabel)) { string markedUp = @"<p><span id=""e4bc05e5-4d65-4016-9bf3-ab44a0df3ea2"" class=""bloom-highlightSegment"" recordingmd5=""undefined"">This elephant is running amok.</span> <span id=""i2ba966b6-4212-4821-9268-04e820e95f50"" class=""bloom-highlightSegment"" recordingmd5=""undefined"">Causing much damage.</span></p>"; ExcelRange textCell = worksheet.Cells[r + 1, c + 1]; Assert.That(textCell.Value.ToString().Contains(markedUp)); break; } } } } }
public void SpreadsheetIOWriteSpreadsheet_HeaderFriendlyNameForImageNotOverwritten() { using (var tempFile = TempFile.WithExtension("xslx")) { SpreadsheetIO.WriteSpreadsheet(_sheetFromExport, tempFile.Path, retainMarkup: false); var info = new FileInfo(tempFile.Path); using (var package = new ExcelPackage(info)) { var worksheet = package.Workbook.Worksheets[0]; var cell = worksheet.Cells[2, 4]; // Note: This uses 1-based index Assert.That(cell.Value.ToString(), Is.EqualTo("Image")); } } }
public void BuildsXmlNested() { //Expect this, but the tag nesting orders can be switched string possibleExpected = "<p><strong>We wish </strong><strong><em><sup>you</sup></em></strong><strong><em><sup><u> a merry </u></sup></em></strong><strong><em><sup>Chri</sup></em></strong><strong><em>stmas</em></strong></p>"; string boldRegex = "<p><strong>We wish <\\/strong>.*<strong>.*you.*<\\/strong>.*<strong>.* a merry .*<\\/strong>.*<strong>.*Chri.*<\\/strong>.*<strong>.*stmas.*<\\/strong>.*</p>"; string italicRegex = "<p>.*We wish .*<em>.*you.*<\\/em>.*<em>.* a merry .*<\\/em>.*<em>.*Chri.*<\\/em>.*<em>.*stmas.*<\\/em>.*</p>"; string underlineRegex = "<p>.*We wish .*you.*<u>.* a merry .*<\\/u>.*Chri.*stmas.*</p>"; string superscriptRegex = "<p>.*We wish .*<sup>.*you.*<\\/sup>.*<sup>.* a merry .*<\\/sup>.*<sup>.*Chri.*<\\/sup>.*stmas.*</p>"; ExcelRange secondCell = _worksheet.Cells[2, 2]; string xmlString = SpreadsheetIO.BuildXmlString(secondCell); Assert.That(xmlString.Length, Is.EqualTo(possibleExpected.Length)); Assert.That(Regex.IsMatch(xmlString, boldRegex)); Assert.That(Regex.IsMatch(xmlString, italicRegex)); Assert.That(Regex.IsMatch(xmlString, underlineRegex)); Assert.That(Regex.IsMatch(xmlString, superscriptRegex)); Assert.That(IsValidXml("wrapper" + xmlString + "wrapper")); }
public void UndoExcelEscapedChars(string input, string expected) { Assert.That(SpreadsheetIO.ReplaceExcelEscapedCharsAndEscapeXmlOnes(input), Is.EqualTo(expected)); }