matthidinger / DoddleReport

Generate custom reports (PDF, Excel, etc) from any IEnumerable datasource.
MIT License
130 stars 40 forks source link

MissingMethodException with latest version #1

Closed jorr-it closed 7 years ago

jorr-it commented 8 years ago

When I upgraded my DoddleReport package from 1.4.0 to 1.5.1, a MissingMethodException was raised when creating a ReportResult object to create a PDF file:

Method not found: Void iTextShap.text.pdf.PdfPTable.AddCell(iTextShap.text.pdf.PdfPCell)

Creating HTML and OpenXML files works fine. Downgrading to 1.4.0 solved the problem again. This is my code:

using DoddleReport;
using DoddleReport.Web;
using DoddleReport.Writers;        

namespace InPRC.Repositories
{
    public class Reports : GenericRepository<InPrcReport>
    {       
        public ReportResult Generate(InPrcReport report, IQueryable<InputCombination> queryPrep)
        {
            List<InPrcReportRow> myList = queryPrep.[Blablabla].ToList();

            var doddle = new Report(myList.ToReportSource());
            doddle.TextFields.SubTitle = "InPRC Report";
            doddle.TextFields.Title = report.Name;
            doddle.TextFields.Footer = [Blablabla];
            doddle.TextFields.Header = string.Format([Blablabla],
                report.Columns,
                DateTime.Now.ToShortDateString(),
                report.Start.ToShortDateString(),
                report.Description);

            foreach (var datafield in doddle.DataFields)
                datafield.Hidden = true;

            foreach (var column in report.ColumnsCollection)
            {
                doddle.DataFields[column].Hidden = false;
                doddle.DataFields[column].HeaderText = this.GetLocalString(column);
            }
            foreach (var row in report.RowsCollection)
            {
                doddle.DataFields[row].Hidden = false;
                doddle.DataFields[row].HeaderText = this.GetLocalString(row);
            }

            string fileName;

            switch (report.Format)
            {
                case "Excel":
                    doddle.Writer = new DoddleReport.OpenXml.ExcelReportWriter();
                    fileName = report.Name + ".xlsx";
                    break;
                case "PDF":
                    doddle.Writer = new DoddleReport.iTextSharp.PdfReportWriter();
                    fileName = report.Name + ".pdf";
                    break;
                default:
                    doddle.Writer = new HtmlReportWriter();
                    fileName = report.Name + ".htm";
                    break;
            }

            return new ReportResult(doddle) { FileName = fileName };
        }
    }
}
matthidinger commented 8 years ago

What version of iTextSharp are you using? The current source references 5.1.1 and I upgraded to 5.5.9 and it's still compiling fine. I did just publish 1.5.2 with a small tweak to fix an issue with iTextSharp 5.5.9 not rendering the rows. Let me know if that fixes things? If not, try update the iTextSharp package?

matthidinger commented 8 years ago

Also I should mention that I removed the iTextSharp package dependency in the DoddleReport.iTextSharp package since some people had it referenced via different means. So if you use the iTextSharp package through nuget make sure that it's installed into your project