Beispiel #1
0
        public void CsvDataString()
        {
            Document doc = new Document(MyDir + "Reporting engine template - CSV data destination.docx");

            CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);

            loadOptions.Delimiter   = ';';
            loadOptions.CommentChar = '$';

            CsvDataSource dataSource = new CsvDataSource(MyDir + "List of people.csv", loadOptions);

            BuildReport(doc, dataSource, "persons");

            doc.Save(ArtifactsDir + "ReportingEngine.CsvDataString.docx");

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "ReportingEngine.CsvDataString.docx",
                                                     GoldsDir + "ReportingEngine.CsvData Gold.docx"));
        }
        public void CsvDataStream()
        {
            Document doc = new Document(MyDir + "ReportingEngine.CsvData.docx");

            CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);

            loadOptions.Delimiter   = ';';
            loadOptions.CommentChar = '$';

            using (FileStream stream = File.OpenRead(MyDir + "CsvData.csv"))
            {
                CsvDataSource dataSource = new CsvDataSource(stream, loadOptions);
                BuildReport(doc, dataSource, "persons");
            }

            doc.Save(ArtifactsDir + "ReportingEngine.CsvDataStream.docx");

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "ReportingEngine.CsvDataStream.docx",
                                                     GoldsDir + "ReportingEngine.CsvData Gold.docx"));
        }