Exemplo n.º 1
0
        private static void GenerateReport(UnitTestResultCollection unitTestResultCollection,
                                           TestSummary testSummaryCollection, string fileName, bool isIncludeOutput)
        {
            var file = new System.IO.FileInfo(fileName);

            if (file.Exists)
            {
                file.Delete();
            }
            using (var p = new Document())
            {
                //set the workbook properties and add a default sheet in it
                PdfWriter.GetInstance(p, new FileStream(fileName, FileMode.Create));
                SetWorkbookProperties(p);
                ////Create a sheet
                p.Open();
                p.AddTitle(unitTestResultCollection.CollectionName.ToString() + " - Test Report");
                p.Add(new Paragraph(unitTestResultCollection.CollectionName + " - Trx2Any Report"));
                BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
                var      times   = new iTextSharp.text.Font(bfTimes, 8, iTextSharp.text.Font.ITALIC, iTextSharp.text.BaseColor.RED);
                p.Add(new Paragraph("This is a report generated by trx2any", times));


                //ExcelWorksheet ws = CreateSheet(p, unitTestResultCollection.CollectionName);
                DataTable dt = CommonUtilities.CreateDataTable(unitTestResultCollection, isIncludeOutput);


                //Create Summary Table
                CreateSummaryHeaders(p, testSummaryCollection);

                CreateHeader(p, dt);
                //CreateData(ws, ref rowIndex, dt);

                //ws.Column(dt.Columns.Count).Width = 100;
                //p.Save();
                p.Close();
            }
        }
Exemplo n.º 2
0
        private static void GenerateReport(UnitTestResultCollection unitTestResultCollection,
                                           TestSummary testSummaryCollection, string fileName, bool isIncludeOutput)
        {
            var file = new System.IO.FileInfo(fileName);

            if (file.Exists)
            {
                file.Delete();
            }
            using (var p = new ExcelPackage(file))
            {
                //set the workbook properties and add a default sheet in it
                SetWorkbookProperties(p);
                //Create a sheet
                ExcelWorksheet ws = CreateSheet(p, unitTestResultCollection.CollectionName);
                DataTable      dt = CommonUtilities.CreateDataTable(unitTestResultCollection, isIncludeOutput);

                ////Merging cells and create a center heading for out table
                ws.Cells[1, 1].Value = "Trx2Any - Trx to Excel Export";
                ws.Cells[1, 1, 1, dt.Columns.Count].Merge                     = true;
                ws.Cells[1, 1, 1, dt.Columns.Count].Style.Font.Bold           = true;
                ws.Cells[1, 1, 1, dt.Columns.Count].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;


                int rowIndex = 2;

                //Create Summary Table
                CreateSummaryHeaders(ws, ref rowIndex, dt.Columns.Count, testSummaryCollection);

                CreateHeader(ws, ref rowIndex, dt);
                CreateData(ws, ref rowIndex, dt);

                ws.Column(dt.Columns.Count).Width = 100;
                p.Save();
            }
        }