asp.net 按指定模板导出word,pdf实例代码(2)


Dictionary<string, string> bookmarks = new Dictionary<string, string>();
bookmarks.Add("ContractDueDateTime", invoice.InvoiceTime.AddDays(invoice.ContractDueDate).ToString("D"));
bookmarks.Add("CustomContactEmail", invoice.CustomContactEmail);
bookmarks.Add("CustomContactName", invoice.CustomContactName);
bookmarks.Add("ContractDueDate", invoice.ContractDueDate.ToString());
bookmarks.Add("CustomContactTel", invoice.CustomContactTel);
bookmarks.Add("CustomAddress", invoice.CustomAddress);
bookmarks.Add("InvoiceTime", invoice.InvoiceTime.ToString());
bookmarks.Add("InvoiceID", invoice.InvoiceID);
bookmarks.Add("CustomName", invoice.CustomName);
bookmarks.Add("CustomName2", invoice.CustomName);
bookmarks.Add("total", invoice.TotalPrice.ToString("C"));
bookmarks.Add("total1", invoice.TotalPrice.ToString("C"));
bookmarks.Add("totalTax", invoice.TotalTax.ToString("C"));
bookmarks.Add("totalPrice", (invoice.TotalPrice + invoice.TotalTax).ToString("C"));
bookmarks.Add("totalPrice1", (invoice.TotalPrice + invoice.TotalTax).ToString("C"));
bookmarks.Add("totalPrice2", (invoice.TotalPrice + invoice.TotalTax).ToString("C"));
bookmarks.Add("totalPrice3", (invoice.TotalPrice + invoice.TotalTax).ToString("C"));
bookmarks.Add("totalPrice4", (invoice.TotalPrice + invoice.TotalTax).ToString("C"));
Utility.GenerateWord(templateFile, fileNameWord, fileNamePdf, bookmarks, invoiceline);



新建一个word,在需要替换的位置插入书签,使用以上方法即可将书签处替换为指定内容,并且另存为pdf

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgzpp.html