public void Exporters_XlsExporter_insertRowLinks_NoLink() { FileInfo outfile = new FileInfo(@"X:\noWhere.xlsx"); string[] exportFields = new string[] { "DOCID", "BEGATT", "VOLUME", "NATIVE" }; Representative.FileType type = Representative.FileType.Native; string display = null; int index = 3; HyperLinkInfo link = new HyperLinkInfo(type, display, index); HyperLinkInfo[] links = new HyperLinkInfo[] { link }; TestExporter tester = new TestExporter(outfile, exportFields, links); DataTable dt = tester.getMetaDataTable(this.docs); FileInfo file = new FileInfo("test.xlsx"); ExcelPackage package = new ExcelPackage(file); ExcelWorksheet ws = package.Workbook.Worksheets.Add("Sheet1"); ws.Cells[1, 1].LoadFromDataTable(dt, true); Document doc = docs[1]; int row = 0; int col = 3; tester.insertRowLinks(ws, dt, doc, row); string expected = String.Empty; string actual = ws.Cells[row + 2, col + 1].Formula; Assert.AreEqual(expected, actual); }
public void Exporters_XlsExporter_insertRowLinks_RelativeLink() { FileInfo outfile = new FileInfo(@"X:\noWhere.xlsx"); string[] exportFields = new string[] { "DOCID", "BEGATT", "VOLUME", "NATIVE" }; Representative.FileType type = Representative.FileType.Native; string display = null; int index = 3; docs.First().Metadata["NATIVE"] = @"\NATIVE\0001\DOC000001.XLSX"; docs.First().Representatives.First().Files["DOC000001"] = @"\NATIVE\0001\DOC000001.XLSX"; HyperLinkInfo link = new HyperLinkInfo(type, display, index); HyperLinkInfo[] links = new HyperLinkInfo[] { link }; TestExporter tester = new TestExporter(outfile, exportFields, links); DataTable dt = tester.getMetaDataTable(this.docs); FileInfo file = new FileInfo("test.xlsx"); ExcelPackage package = new ExcelPackage(file); ExcelWorksheet ws = package.Workbook.Worksheets.Add("Sheet1"); ws.Cells[1, 1].LoadFromDataTable(dt, true); Document doc = docs.First(); int row = 0; int col = 3; string linkValue = @".\NATIVE\0001\DOC000001.XLSX"; tester.insertRowLinks(ws, dt, doc, row); string expected = String.Format( "HYPERLINK(\"{0}\", \"{1}\")", linkValue, "\\NATIVE\\0001\\DOC000001.XLSX"); string actual = ws.Cells[row + 2, col + 1].Formula; Assert.AreEqual(expected, actual); }