This second method takes a lot more time and effort. The most popular method is selecting an invoice template from their portfolio, and the second option is to construct the invoice style and template from scratch in Word. In general, there are two ways to create an invoice in Word. This is how the final Invoice document looks:īe sure to download the sample implementing the Invoice generation scenario using the Report Templates feature of GcWord API.Making an invoice in Microsoft Word is an easy process. Invoke the Save method to save the processed data-bound document.Invoke the Process method to replace the tags with data while iterating over all data items.Fetch the data for the template invoking the method defined above and add it to the template's datasources using the Add method of GcWord APIĭoc.("ds", data).Instantiate an instance of GcWordDocument and load the InvoiceTemplate.docx into it.ĭoc.Load(Path.Combine("Resources", "WordDocs", "InvoiceTemplate.docx")).Var x = new string(companyName.ToLower().Where(c_ => char.IsLetterOrDigit(c_)).ToArray()) Īfter generating the template datasource and creating the report template saved in DOCX format using the steps above, follow these steps to process the template and generate the document (using C#): Public static GetEmail(string firstName, string lastName, string companyName) Total = orderDetails.Sum(od_ => od_.Total), Finally, prep the integrated data source for the template: Total = Convert.ToDecimal(it) * Convert.ToDecimal(it), Var orderDetails = dtOrdersDetails.Select() After adding the static text and structural elements, we must add tags using the Mustache syntax "",Įmail = GetEmail(it.ToString(), it.ToString(), it.ToString()) Add the required structural elements, which is a Table displaying the list of ordered products.Add labels and paragraphs as required to display static text.Design the Report Template by creating a new Word document.The Invoice template shown below was created using MS Word, following the steps below: Refer to the documentation for a detailed understanding of template tags. GcWord API supports a set of template tags divided into Value Tags and Range Tags, used to create the Report Template. Add a reference to namespace in Program.cs file, using the following code:.Install package using Nuget package manager in the application.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |