Dear Team,
I am binding .Net Data source to my template. But i am getting above subjected error. Please find image link below.
// Get the customer object with the Id = 15.
InvoiceModel customer = new InvoiceModel()
{
Amount = 100,
CustomerAddress = "4/46, uppupalayam east",
CustomerName = "Sakthi",
InvoiceComment = " Test Comment",
InvoiceDate = DateTime.Now,
InvoiceRef = "REF1234",
PaidAmount = 2000,
ProductName = "Metformin 500",
Qty = 1000,
TaxAmount = 100,
UnitCost = 2
};
IEnumerable<invoicemodel> invoiceModels = new List<invoicemodel>() { customer };
// Create a temporary file for the generated report document.
string reportDocumentTemplate = @"C:\Users\User\Documents\DocentricInvoiceTemplate.docx";
string reportDocumentReport = @"C:\Users\User\Documents\DocentricInvoiceReport.docx";
using (Stream reportDocumentStream = File.Create(reportDocumentReport))
{
// Open the report template file.
using (Stream reportTemplateStream = new FileStream(reportDocumentTemplate, FileMode.Open))
{
// Generate the report document using 'DocumentGenerator'.
DocumentGenerator dg = new DocumentGenerator(invoiceModels.First());
DocumentGenerationResult result = dg.GenerateDocument(reportTemplateStream, reportDocumentStream);
if (result.HasErrors)
{
//foreach (Word.Error error in result.Errors) Console.Out.WriteLine(error.Message);
}
}
}
return reportDocumentReport;
Regards, Sakthi