private static void ConvertXlsxToTextFile(string xlsxFilepath, string txtFilePath) { using (var outputStream = new FileWriter(txtFilePath)) { var inputFile = new FileInfo(xlsxFilepath); var xlsxDocument = new XlsxDocumentReader().Read(inputFile); new XlsxDocumentPrinter(new CenterAlignmentTextFormatter(), outputStream).Print(xlsxDocument); } }
public void Convert(FileInfo xlsxFile) { using (ApprovalResults.ForScenario(xlsxFile.Name)) { var sb = new StringBuilder(); var xlsxDocument = new XlsxDocumentReader().Read(xlsxFile); new XlsxDocumentPrinter(new CenterAlignmentTextFormatter(), new StringBuilderWriter(sb)).Print(xlsxDocument); Approvals.Verify(sb.ToString()); } }
private static void Convert(string filepath) { try { var inputFile = new FileInfo(filepath); var xlsxDocument = new XlsxDocumentReader().Read(inputFile); new XlsxDocumentPrinter(new CenterAlignmentTextFormatter(), new ConsoleWriter()).Print(xlsxDocument); } catch (Exception exception) { Console.WriteLine($"Exception: {exception}"); } }
public void ExtractFromMovements(string lessonNumber) { using (ApprovalResults.ForScenario(lessonNumber)) { var xlsxFile = TestDataDirectory.GetOrCreateSubDirectory("InputData") .GetFiles() .First(x => x.Name == "Movements.xlsx"); var document = new XlsxDocumentReader().Read(xlsxFile.FullName); var movements = new LessonMovementsExtractor().Extract(document, lessonNumber); var json = JsonConvert.SerializeObject(movements, Formatting.Indented); Approvals.VerifyJson(json); } }
public void TestDiscoverBuiltInSpreadsheetProperties() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestAllDocProperties.xlsx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.BuiltInProperty).Count, 0, "No builtin property types found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.BuiltInProperty)[0]; //CommonTestUtilities.CheckNode(ttProps, "Template", ""); CommonTestUtilities.CheckNode(ttProps, "Manager", "mgrPair"); CommonTestUtilities.CheckNode(ttProps, "Company", "Workshare"); //CommonTestUtilities.CheckNode(ttProps, "HyperlinkBase", @"http:\\madeup"); } }
public void TestDiscoverCoreSpreadsheetProperties() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestAllDocProperties.xlsx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.BuiltInProperty).Count, 0, "No coreproperties types found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.BuiltInProperty)[0]; CommonTestUtilities.CheckNode(ttProps, "Title", "TestAllDocumentProperties"); CommonTestUtilities.CheckNode(ttProps, "Subject", "Testing xlsx document properties"); CommonTestUtilities.CheckNode(ttProps, "Author", "pair"); CommonTestUtilities.CheckNode(ttProps, "Keywords", "Key"); CommonTestUtilities.CheckNode(ttProps, "Description", "commentary"); CommonTestUtilities.CheckNode(ttProps, "Category", "Testing"); } }
private static void CreateLesson(LessonDocumentCreatingOptions options) { var excelDocumentReader = new XlsxDocumentReader(); var lessonExtractor = new LessonMovementsExtractor(); var movementsDocument = excelDocumentReader.Read(options.MovementsFile.FullName); var warmupMovementsDocument = excelDocumentReader.Read(options.WarmupMovementsFile.FullName); var movements = lessonExtractor.Extract(movementsDocument, options.LessonNumber); var warmupMovements = lessonExtractor.Extract(warmupMovementsDocument, options.LessonNumber); using (var writer = new FileWriter(options.LessonFilename)) { new LessonPrinter().Print(warmupMovements, movements, writer); } }
private static void ValidateLesson(LessonDocumentValidationOptions options) { var excelDocumentReader = new XlsxDocumentReader(); var lessonExtractor = new LessonMovementsExtractor(); var movementsDocument = excelDocumentReader.Read(options.MovementsFile.FullName); var warmupMovementsDocument = excelDocumentReader.Read(options.WarmupMovementsFile.FullName); var movements = lessonExtractor.Extract(movementsDocument, options.LessonNumber); var warmupMovements = lessonExtractor.Extract(warmupMovementsDocument, options.LessonNumber); var lesson = new LessonDocumentReader().Read(options.LessonFile.FullName); var validationResult = new LessonValidator().Validate(warmupMovements, movements, lesson); using (var writer = new FileWriter(options.ValidationResultFilename)) { new ValidationResultPrinter().Print(validationResult, writer); } }
public void TestDiscoverSpreadsheetStatisticsProperties() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestAllDocProperties.xlsx")) { DocumentText dt = reader.Read(); Assert.Greater(dt.GetTextTypes(ContentType.DocumentStatistic).Count, 0, "No coreproperties types found"); IAbstractTextType ttProps = dt.GetTextTypes(ContentType.DocumentStatistic)[0]; // doc stats CommonTestUtilities.CheckNode(ttProps, "LastAuthor", "lnpair"); // CommonTestUtilities.CheckNode(ttProps, "RevisionNumber", ""); // ChWinTime (an exact copy of Windows' FILETIME structure) to FILETIME convert CommonTestUtilities.CheckNode(ttProps, "CreatedTime", "2006-01-30T16:20:51Z"); CommonTestUtilities.CheckNode(ttProps, "LastPrintedTime", "2007-01-12T15:41:17Z"); CommonTestUtilities.CheckNode(ttProps, "LastSaveTime", "2007-01-12T15:41:23Z"); //CommonTestUtilities.CheckNode(ttProps, "EditTime", ""); } }
public void TestDiscoverSpreadsheetWithComment() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Comments.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType ttComment = dt.GetTextTypes(ContentType.Comment)[0]; Assert.AreEqual(2, ttComment.GetChildCount(), "expected to find 2 comments"); IAbstractTextNode node = ttComment.GetChild(0); Assert.AreEqual("maggieh:\nThis is a comment here", node.GetInfo("Content")[0].value, "wrong comment text reported"); Assert.AreEqual("maggieh", node.GetInfo("Author")[0].value, "wrong comment author reported"); Assert.AreEqual("A1", node.GetInfo("Ref")[0].value, "wrong comment ref reported"); Assert.AreEqual("0", node.GetInfo("AuthorId")[0].value, "wrong comment author id reported"); node = ttComment.GetChild(1); Assert.AreEqual("lnpair:\nSecond comment here. Let's see", node.GetInfo("Content")[0].value, "wrong comment text reported"); Assert.AreEqual("lnpair", node.GetInfo("Author")[0].value, "wrong comment author reported"); Assert.AreEqual("B7", node.GetInfo("Ref")[0].value, "wrong comment ref reported"); Assert.AreEqual("1", node.GetInfo("AuthorId")[0].value, "wrong comment author id reported"); } }
public void TestDiscoverSmallText() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Small Text.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.SmallText)[0]; Assert.AreEqual(4, textType.GetChildCount(), "expected to find 4 bits of small text"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("this bit is small", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("8", testNode.GetInfo("Row")[0].value); Assert.AreEqual("E", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("3", testNode.GetInfo("StringIndex")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("and then this bit is", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("8", testNode.GetInfo("Row")[0].value); Assert.AreEqual("E", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("3", testNode.GetInfo("StringIndex")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("this is smaller text", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("Row")[0].value); Assert.AreEqual("D", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("4", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("1", testNode.GetInfo("StringIndex")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("this is tiny", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("10", testNode.GetInfo("Row")[0].value); Assert.AreEqual("C", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("2", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("2", testNode.GetInfo("StringIndex")[0].value); } }
public void TestDiscoverWhiteText() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test White Text.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.WhiteText)[0]; Assert.AreEqual(2, textType.GetChildCount(), "expected to find 2 bits of white text"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("here some of", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("8", testNode.GetInfo("Row")[0].value); Assert.AreEqual("D", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("2", testNode.GetInfo("StringIndex")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("simple white text", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("Row")[0].value); Assert.AreEqual("B", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("1", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("0", testNode.GetInfo("StringIndex")[0].value); } }
public void TestDiscoverHiddenColumn() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestCellContent.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.HiddenColumn)[0]; Assert.AreEqual(5, textType.GetChildCount(), "expected to find 5 hidden columns "); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("6", testNode.GetInfo("Column")[0].value); Assert.AreEqual("6", testNode.GetInfo("Max")[0].value); Assert.AreEqual("0", testNode.GetInfo("Width")[0].value); Assert.AreEqual("1", testNode.GetInfo("CustomWidth")[0].value); Assert.AreEqual("1", testNode.GetInfo("Hidden")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("14", testNode.GetInfo("Column")[0].value); Assert.AreEqual("14", testNode.GetInfo("Max")[0].value); Assert.AreEqual("0", testNode.GetInfo("Width")[0].value); Assert.AreEqual("1", testNode.GetInfo("CustomWidth")[0].value); Assert.AreEqual("1", testNode.GetInfo("Hidden")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("15", testNode.GetInfo("Column")[0].value); Assert.AreEqual("15", testNode.GetInfo("Max")[0].value); Assert.AreEqual("0", testNode.GetInfo("Width")[0].value); Assert.AreEqual("1", testNode.GetInfo("CustomWidth")[0].value); Assert.AreEqual("1", testNode.GetInfo("Hidden")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("16", testNode.GetInfo("Column")[0].value); Assert.AreEqual("16", testNode.GetInfo("Max")[0].value); Assert.AreEqual("0", testNode.GetInfo("Width")[0].value); Assert.AreEqual("1", testNode.GetInfo("CustomWidth")[0].value); Assert.AreEqual("1", testNode.GetInfo("Hidden")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("I am hidden", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("5", testNode.GetInfo("Column")[0].value); Assert.AreEqual("5", testNode.GetInfo("Max")[0].value); Assert.AreEqual("0", testNode.GetInfo("Width")[0].value); Assert.AreEqual("1", testNode.GetInfo("CustomWidth")[0].value); Assert.AreEqual("1", testNode.GetInfo("Hidden")[0].value); } }
public void TestDiscoverFooters() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Footers.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.Footer)[0]; Assert.AreEqual(7, textType.GetChildCount()); int index = 0; IAbstractTextNode testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Regular Footers", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&A", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Chart with Footers", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&A", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Custom Footers", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&LLeft bit of garbage&CSomething in the middle&RRight bit of garbage", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Macro1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&L&8{C7E7CD2B-52F4-4e2a-B016-587816903E84}", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Dialog1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&L&8{CB991023-4D3B-4a92-8564-54FC074AB78F}", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Macro2", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&R{04FA4A66-446F-437d-94CA-811E48EA67E5}\n", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Sheet with embedded chart", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&A", testNode.GetInfo("Content")[0].value); } }
public void TestDiscoverMacroSheetsAsMacros() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestMacroSheets.xlsm")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.Macro)[0]; Assert.AreEqual(2, textType.GetChildCount()); int index = 0; IAbstractTextNode macrosNode = textType.GetChild(index++); Assert.IsNotNull(macrosNode); Assert.AreEqual("application/vnd.ms-excel.macrosheet+xml", macrosNode.GetInfo("Type")[0].value); Assert.AreEqual("rId6", macrosNode.GetInfo("Id")[0].value); Assert.AreEqual("macrosheets/sheet1.xml", macrosNode.GetInfo("Target")[0].value); macrosNode = textType.GetChild(index++); Assert.IsNotNull(macrosNode); Assert.AreEqual("application/vnd.ms-excel.intlmacrosheet+xml", macrosNode.GetInfo("Type")[0].value); Assert.AreEqual("rId7", macrosNode.GetInfo("Id")[0].value); Assert.AreEqual("macrosheets/intlsheet1.xml", macrosNode.GetInfo("Target")[0].value); } }
public void TestDiscoverTrackChanges_DeletedRows() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Deleted Rows TrackChanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(9, textType.GetChildCount(), "expected to find 9 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Additional", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("yes I think so", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("no", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("yes", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("F4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("1", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("deleteRow", testNode.GetInfo("Action")[0].value); Assert.AreEqual("A4:XFD4", testNode.GetInfo("CellRefs")[0].value); Assert.AreEqual("Additionalyes I think sonoyes", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Secondary", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A6", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("putting in stuff", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C6", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("blurble", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D6", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("2", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("deleteRow", testNode.GetInfo("Action")[0].value); Assert.AreEqual("A6:XFD6", testNode.GetInfo("CellRefs")[0].value); Assert.AreEqual("Secondaryputting in stuffblurble", testNode.GetInfo("Content")[0].value); } }
public void TestDiscoverTrackChanges_Moved() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Moved TrackChanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(1, textType.GetChildCount(), "expected to find 1 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("more stuff", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("DestinationSheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SourceSheetId")[0].value); Assert.AreEqual("B5", testNode.GetInfo("SourceCellRef")[0].value); Assert.AreEqual("D4", testNode.GetInfo("DestinationCellRef")[0].value); Assert.AreEqual("Move", testNode.GetInfo("ContentType")[0].value); } }
public void TestDiscoverTextInTables() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Simple Theme Table.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.SmallText)[0]; Assert.AreEqual(1, textType.GetChildCount(), "expected to find 1 bit of small text"); IAbstractTextNode testNode = textType.GetChild(0); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("Third", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("4", testNode.GetInfo("Row")[0].value); Assert.AreEqual("A", testNode.GetInfo("Column")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("4", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("6", testNode.GetInfo("StringIndex")[0].value); textType = dt.GetTextTypes(ContentType.RedactedText)[0]; Assert.AreEqual(1, textType.GetChildCount(), "expected to find 1 bit of redacted text"); testNode = textType.GetChild(0); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("5", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("4", testNode.GetInfo("Row")[0].value); Assert.AreEqual("B", testNode.GetInfo("Column")[0].value); Assert.AreEqual("node_processed", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("3", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StringIndex")[0].value); textType = dt.GetTextTypes(ContentType.WhiteText)[0]; Assert.AreEqual(1, textType.GetChildCount(), "expected to find 1 bit of white text"); testNode = textType.GetChild(0); Assert.IsNotNull(testNode); Assert.AreEqual(8, testNode.GetInfoCount()); Assert.AreEqual("3", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("3", testNode.GetInfo("Row")[0].value); Assert.AreEqual("B", testNode.GetInfo("Column")[0].value); Assert.AreEqual("node_processed", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("1", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StringIndex")[0].value); } }
public void TestDiscoverDiagrams() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Text Xlsx Smart Art.xlsx")) { DocumentText dt = reader.Read(); TextType ttWhiteText = dt.GetTextTypes(ContentType.WhiteText)[0] as TextType; Assert.AreEqual(2, ttWhiteText.GetChildCount(), "expected it to find 2 white text items"); TextType ttParagraphText = dt.GetTextTypes(ContentType.Paragraph)[0] as TextType; Assert.AreEqual(5, ttParagraphText.GetChildCount(), "expected it to find 5 paragraph text items"); } }
public void TestDiscoverXlsxWithCorrectCustomPropertyTypes() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Custom Property.xlsx")) { DocumentText dt = reader.Read(); TextType ttCustProps = dt.GetTextTypes(ContentType.CustomProperty)[0] as TextType; Assert.IsNotNull(ttCustProps); Assert.AreEqual(4, ttCustProps.GetChildCount()); Assert.AreEqual("SPECIAL", ttCustProps.GetChild(0).GetInfo("Name")[0].value); Assert.AreEqual("666", ttCustProps.GetChild(0).GetInfo("Value")[0].value); Assert.AreEqual(DataType.Long, ttCustProps.GetChild(0).GetInfo("Value")[0].type); Assert.AreEqual("Another", ttCustProps.GetChild(1).GetInfo("Name")[0].value); Assert.AreEqual("textual", ttCustProps.GetChild(1).GetInfo("Value")[0].value); Assert.AreEqual(DataType.String, ttCustProps.GetChild(1).GetInfo("Value")[0].type); Assert.AreEqual("Third", ttCustProps.GetChild(2).GetInfo("Name")[0].value); Assert.AreEqual("true", ttCustProps.GetChild(2).GetInfo("Value")[0].value); Assert.AreEqual(DataType.Boolean, ttCustProps.GetChild(2).GetInfo("Value")[0].type); Assert.AreEqual("last", ttCustProps.GetChild(3).GetInfo("Name")[0].value); Assert.AreEqual("2002-07-12T23:00:00Z", ttCustProps.GetChild(3).GetInfo("Value")[0].value); Assert.AreEqual(DataType.FileTime, ttCustProps.GetChild(3).GetInfo("Value")[0].type); } }
public void TestDiscoverHiddenSheetWithComment() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test HiddenSheet with other content.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType ttHiddenSheet = dt.GetTextTypes(ContentType.HiddenSheet)[0]; Assert.AreEqual(1, ttHiddenSheet.GetChildCount(), "expected to find 1 hidden sheet"); IAbstractTextType ttComment = dt.GetTextTypes(ContentType.Comment)[0]; Assert.AreEqual(2, ttComment.GetChildCount(), "expected to find 2 comments"); IAbstractTextNode node = ttComment.GetChild(0); Assert.AreEqual("Author:\ncomment on another sheet", node.GetInfo("Content")[0].value, "wrong comment text reported"); Assert.AreEqual("Author", node.GetInfo("Author")[0].value, "wrong comment author reported"); Assert.AreEqual("B7", node.GetInfo("Ref")[0].value, "wrong comment ref reported"); Assert.AreEqual("0", node.GetInfo("AuthorId")[0].value, "wrong comment author id reported"); node = ttComment.GetChild(1); Assert.AreEqual("Author:\ncomment on a hidden sheet", node.GetInfo("Content")[0].value, "wrong comment text reported"); Assert.AreEqual("Author", node.GetInfo("Author")[0].value, "wrong comment author reported"); Assert.AreEqual("C4", node.GetInfo("Ref")[0].value, "wrong comment ref reported"); Assert.AreEqual("0", node.GetInfo("AuthorId")[0].value, "wrong comment author id reported"); } }
public void TestDiscoverHyperlinkInDrawing() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Hyperlink In Drawing.xlsm")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.Hyperlink)[0]; Assert.AreEqual(1, textType.GetChildCount(), "Expected to only have 1 Hyperlink"); IAbstractTextNode testNode = textType.GetChild(0); Assert.IsNotNull(testNode); Assert.AreEqual(@"www.umass.edu/procurement/contracts/printing.html", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Drawing Hyperlink", testNode.GetInfo("Type")[0].value); //Assert.AreEqual("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", testNode.GetInfo("Type")[0].value); //Assert.AreEqual(@"http://www.umass.edu/procurement/contracts/printing.html#www.umass.edu/procurement/contracts/printing.html
", testNode.GetInfo("Target")[0].value); Assert.AreEqual("rId1", testNode.GetInfo("Id")[0].value); } }
public void TestMultipleSheetsMultipleTextTypes() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Multiple Sheets Multiple Types.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType celltextType = dt.GetTextTypes(ContentType.CellText)[0]; IAbstractTextType coltextType = dt.GetTextTypes(ContentType.HiddenColumn)[0]; IAbstractTextType rowtextType = dt.GetTextTypes(ContentType.HiddenRow)[0]; IAbstractTextType redactedtextType = dt.GetTextTypes(ContentType.RedactedText)[0]; IAbstractTextType smalltextType = dt.GetTextTypes(ContentType.SmallText)[0]; IAbstractTextType whitetextType = dt.GetTextTypes(ContentType.WhiteText)[0]; IAbstractTextType hiddentextType = dt.GetTextTypes(ContentType.HiddenText)[0]; Assert.AreEqual(12, celltextType.GetChildCount()); Assert.AreEqual(2, coltextType.GetChildCount()); Assert.AreEqual(2, rowtextType.GetChildCount()); Assert.AreEqual(1, redactedtextType.GetChildCount()); Assert.AreEqual(1, smalltextType.GetChildCount()); Assert.AreEqual(2, whitetextType.GetChildCount()); Assert.AreEqual(4, hiddentextType.GetChildCount()); } }
public void TestDiscoverExternalFileLinks() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestFileExternalLinks.xlsm")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.Links)[0]; Assert.AreEqual(1, textType.GetChildCount()); IAbstractTextNode testNode = textType.GetChild(0); Assert.IsNotNull(testNode); Assert.AreEqual("File Link", testNode.GetInfo("Type")[0].value); Assert.AreEqual("Document", testNode.GetInfo("ProgId")[0].value); Assert.AreEqual("", testNode.GetInfo("RefIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("RefName")[0].value); Assert.AreEqual(@"file:///\\nt30\webteam\COMMON\Energy%20A\Reports\PINWST\PinWSt98.xls", testNode.GetInfo("Path")[0].value); Assert.AreEqual(@"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath", testNode.GetInfo("LinkType")[0].value); } }
public void TestDiscoverTrackChanges() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "simple track changes.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(3, textType.GetChildCount(), "expected to find 3 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("added this", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D2", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("more words in this sheet", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("more wet", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); } }
public void TestDiscoverTrackChanges_Complex() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test More complex trackchanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(30, textType.GetChildCount(), "expected to find 30 trackchanges"); #region NodeTests int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Fifth", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("yes", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G5", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("23", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G10", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("15", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("deleteCol", testNode.GetInfo("Action")[0].value); Assert.AreEqual("G1:G1048576", testNode.GetInfo("CellRefs")[0].value); Assert.AreEqual("Fifthyes23", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Sideline", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("some stuff", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("bits here", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("next one is blank", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("E3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("adding this", testNode.GetInfo("Content")[0].value); Assert.AreEqual("0", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("16", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("deleteRow", testNode.GetInfo("Action")[0].value); Assert.AreEqual("A3:XFD3", testNode.GetInfo("CellRefs")[0].value); Assert.AreEqual("Sidelinesome stuffbits herenext one is blankadding this", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("1", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("insertCol", testNode.GetInfo("Action")[0].value); Assert.AreEqual("H1:H1048576", testNode.GetInfo("CellRefs")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Sixth", testNode.GetInfo("Content")[0].value); Assert.AreEqual("2", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("H1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("adding this", testNode.GetInfo("Content")[0].value); Assert.AreEqual("3", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("H3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("666", testNode.GetInfo("Content")[0].value); Assert.AreEqual("4", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("H9", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Seconday", testNode.GetInfo("Content")[0].value); Assert.AreEqual("5", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Secondary", testNode.GetInfo("Content")[0].value); Assert.AreEqual("5", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Foruth", testNode.GetInfo("Content")[0].value); Assert.AreEqual("6", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("F1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Fourth", testNode.GetInfo("Content")[0].value); Assert.AreEqual("6", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("F1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("yes ", testNode.GetInfo("Content")[0].value); Assert.AreEqual("7", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("E5", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("no", testNode.GetInfo("Content")[0].value); Assert.AreEqual("7", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("E5", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("putting in stuff", testNode.GetInfo("Content")[0].value); Assert.AreEqual("8", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("9", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("insertRow", testNode.GetInfo("Action")[0].value); Assert.AreEqual("A6:XFD6", testNode.GetInfo("CellRefs")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Extra row here", testNode.GetInfo("Content")[0].value); Assert.AreEqual("10", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A6", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("1007", testNode.GetInfo("Content")[0].value); Assert.AreEqual("11", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C10", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("11007", testNode.GetInfo("Content")[0].value); Assert.AreEqual("11", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C10", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("122512554555125", testNode.GetInfo("Content")[0].value); Assert.AreEqual("12", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D10", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("no ", testNode.GetInfo("Content")[0].value); Assert.AreEqual("13", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D5", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("yes I think so", testNode.GetInfo("Content")[0].value); Assert.AreEqual("13", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D5", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("First column", testNode.GetInfo("Content")[0].value); Assert.AreEqual("14", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("First", testNode.GetInfo("Content")[0].value); Assert.AreEqual("14", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); #endregion } }
public void TestDiscoverTrackChanges_DeletedColumns() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Deleted columns trackchanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(8, textType.GetChildCount(), "expected to find 8 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("First", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("yes", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("more things", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("11007", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("C9", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("1", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("deleteCol", testNode.GetInfo("Action")[0].value); Assert.AreEqual("C1:C1048576", testNode.GetInfo("CellRefs")[0].value); Assert.AreEqual("Firstyesmore things11007", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("Fourth", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("E1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("no ", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("E4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("2", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("deleteCol", testNode.GetInfo("Action")[0].value); Assert.AreEqual("E1:E1048576", testNode.GetInfo("CellRefs")[0].value); Assert.AreEqual("Fourthno ", testNode.GetInfo("Content")[0].value); } }
public void TestDiscoverTrackChanges_InsertedColumns() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test inserted columns trackchanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(6, textType.GetChildCount(), "expected to find 6 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("this text is also in the new column, but it is going to be deleted", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("B4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("1", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("insertCol", testNode.GetInfo("Action")[0].value); Assert.AreEqual("B1:B1048576", testNode.GetInfo("CellRefs")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("this is text in the newly inserted column", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("B1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("this text is also in the new column, but it is going to be deleted", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("B4", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("4", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("insertCol", testNode.GetInfo("Action")[0].value); Assert.AreEqual("D1:D1048576", testNode.GetInfo("CellRefs")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("added another column and this is the content", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D5", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); } }
public void TestDiscoverCommentTextAsCellTextForContentAnalysisChecks() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "SimpleComment.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.CellText)[0]; Assert.AreEqual(1, textType.GetChildCount(), "Expected just teh comment text as single celltext object"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual("Author:\nThis is comment text", testNode.GetInfo("Content")[0].value); } }
public void TestDiscoverMacros() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Macros.xlsm")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.Macro)[0]; Assert.AreEqual(1, textType.GetChildCount()); int index = 0; IAbstractTextNode macrosNode = textType.GetChild(index++); Assert.IsNotNull(macrosNode); Assert.AreEqual("application/vnd.ms-office.vbaProject", macrosNode.GetInfo("Type")[0].value); Assert.AreEqual("rId6", macrosNode.GetInfo("Id")[0].value); Assert.AreEqual("vbaProject.bin", macrosNode.GetInfo("Target")[0].value); } }
public void TestDiscoverTrackChanges_InsertedRows() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test inserted rows trackchanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(9, textType.GetChildCount(), "expected to find 9 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("added this row,but going to delete this text", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Deletion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("1", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("insertRow", testNode.GetInfo("Action")[0].value); Assert.AreEqual("A3:XFD3", testNode.GetInfo("CellRefs")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("inserted this row here", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("inserted this text here ", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("more stuff inserted", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G3", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("5", testNode.GetInfo("rID")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); Assert.AreEqual("insertRow", testNode.GetInfo("Action")[0].value); Assert.AreEqual("A7:XFD7", testNode.GetInfo("CellRefs")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("additional row added here", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("and here is some more", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("D7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("added this row,but going to delete this text", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("G7", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); } }
public void TestDiscoverInkAnnotation_1() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Ink Annotations.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.InkAnnotation)[0]; Assert.AreEqual(1, textType.GetChildCount(), "Expected one annotation"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual("_x0000_s1026", testNode.GetInfo("ShapeId")[0].value); } }
public void TestDiscoverTrackChanges_InsertedSheets() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test inserted sheets trackchanges.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.TrackChange)[0]; Assert.AreEqual(2, textType.GetChildCount(), "expected to find 6 trackchanges"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(5, testNode.GetInfoCount()); Assert.AreEqual("1", testNode.GetInfo("rID")[0].value); Assert.AreEqual("[Test Inserted and Deleted Sheets TrackChanges.xlsx]Sheet4", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("4", testNode.GetInfo("SheetId")[0].value); Assert.AreEqual("3", testNode.GetInfo("SheetPosition")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual(6, testNode.GetInfoCount()); Assert.AreEqual("this is on an inserted sheet", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet4", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("A1", testNode.GetInfo("CellRef")[0].value); Assert.AreEqual("Insertion", testNode.GetInfo("ContentType")[0].value); } }
public void TestDiscoverHeaders() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "Test Headers.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.Header)[0]; Assert.AreEqual(7, textType.GetChildCount()); int index = 0; IAbstractTextNode testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Custom Headers", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&LWorkshare&CWelcome&R&Z&F", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Simple Page X of Y Header", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("Page &P of &N", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Just a chart with a header", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&CJaC", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Macro2", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&L&8{29C79BE2-0EFF-4579-8A33-8E1A430CC961}&10\n", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Macro1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&L&8{99479469-C409-4862-8C1C-93371C8E8B85}", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Dialog1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&C&8{468DA39D-E876-43eb-8E19-1CA1391AE90D}", testNode.GetInfo("Content")[0].value); testNode = textType.GetChild(index++); Assert.IsNotNull(testNode); Assert.AreEqual("Chart and Sheet with Header", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("&CEmbedded chart", testNode.GetInfo("Content")[0].value); } }
public void TestDiscoverSpreadSheetCellContent() { using (XlsxDocumentReader reader = new XlsxDocumentReader(TESTFILE_DIR + "TestCellContent.xlsx")) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.CellText)[0]; Assert.AreEqual(9, textType.GetChildCount(), "expected to find 7 cell texts"); int index = 0; IAbstractTextNode testNode = textType.GetChild(index); Assert.IsNotNull(testNode); Assert.AreEqual(7, testNode.GetInfoCount()); Assert.AreEqual("This is some text in a cell", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("1", testNode.GetInfo("Row")[0].value); Assert.AreEqual("A", testNode.GetInfo("Column")[0].value); Assert.AreEqual("0", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("This is some more text in a cell", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("3", testNode.GetInfo("Row")[0].value); Assert.AreEqual("J", testNode.GetInfo("Column")[0].value); Assert.AreEqual("1", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Some small text", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("4", testNode.GetInfo("Row")[0].value); Assert.AreEqual("A", testNode.GetInfo("Column")[0].value); Assert.AreEqual("7", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("2", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Some text pt of which is small", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("6", testNode.GetInfo("Row")[0].value); Assert.AreEqual("D", testNode.GetInfo("Column")[0].value); Assert.AreEqual("8", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Text in a hidden column", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("6", testNode.GetInfo("Row")[0].value); Assert.AreEqual("F", testNode.GetInfo("Column")[0].value); Assert.AreEqual("2", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Text in a hidden row", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("9", testNode.GetInfo("Row")[0].value); Assert.AreEqual("D", testNode.GetInfo("Column")[0].value); Assert.AreEqual("3", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("This is white text", testNode.GetInfo("Content")[0].value); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("12", testNode.GetInfo("Row")[0].value); Assert.AreEqual("B", testNode.GetInfo("Column")[0].value); Assert.AreEqual("4", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("1", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Text on a hidden sheet", testNode.GetInfo("Content")[0].value); Assert.AreEqual("I am hidden", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("5", testNode.GetInfo("Row")[0].value); Assert.AreEqual("C", testNode.GetInfo("Column")[0].value); Assert.AreEqual("5", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); testNode = textType.GetChild(++index); Assert.IsNotNull(testNode); Assert.AreEqual("Text on a hidden sheet in a hidden column and hidden row", testNode.GetInfo("Content")[0].value); Assert.AreEqual("I am hidden", testNode.GetInfo("SheetName")[0].value); Assert.AreEqual("13", testNode.GetInfo("Row")[0].value); Assert.AreEqual("E", testNode.GetInfo("Column")[0].value); Assert.AreEqual("6", testNode.GetInfo("StringIndex")[0].value); Assert.AreEqual("", testNode.GetInfo("StyleIndex")[0].value); Assert.AreEqual("s_node_processed", testNode.GetInfo("ContentType")[0].value); } }
public void TestDiscoverWhiteTextInMediumThemedTables() {//there are 28 default light table themes for (int i = 1; i < 29; i++) { string testDocumentName = TESTFILE_DIR + "Test Table Medium " + i.ToString() + ".xlsx"; using (XlsxDocumentReader reader = new XlsxDocumentReader(testDocumentName)) { DocumentText dt = reader.Read(); IAbstractTextType textType = dt.GetTextTypes(ContentType.CellText)[0]; Assert.AreEqual(11, textType.GetChildCount(), "expected to find 11 bit of small text in " + testDocumentName); Assert.AreEqual(4, dt.GetTextTypes().Count, "Should only have four text types in " + testDocumentName); textType = dt.GetTextTypes(ContentType.WhiteText)[0]; IAbstractTextNode testNode = textType.GetChild(0); Assert.IsNotNull(testNode); Assert.AreEqual("5", testNode.GetInfo("Content")[0].value, "Wrong content reported for " + testDocumentName); Assert.AreEqual("Sheet1", testNode.GetInfo("SheetName")[0].value, "Wrong sheet reported for " + testDocumentName); Assert.AreEqual("4", testNode.GetInfo("Row")[0].value, "Wrong Row reported for " + testDocumentName); Assert.AreEqual("B", testNode.GetInfo("Column")[0].value, "Wrong Column reported for " + testDocumentName); Assert.AreEqual("node_processed", testNode.GetInfo("ContentType")[0].value, "Wrong Content Type reported for " + testDocumentName); Assert.AreEqual("1", testNode.GetInfo("StyleIndex")[0].value, "Wrong Style Index reported for " + testDocumentName); Assert.AreEqual("", testNode.GetInfo("StringIndex")[0].value, "Wrong String Index reported for " + testDocumentName); } } }