Hi There,
Thank for help me,
I have attach file TemplateThongTri.doc
but your example use Aspose.Words for .NET 15.11.0 and i do not have it. I have ver 10.7.
Can you help me with Aspose.Words version10.7.0 and my file template(TemplateThongTri.doc).
now, i do it :
doc.MailMerge.Execute(
new string[] { "LoaiThongTri", "TitleThongTri", "TenDonVi", "NamKeHoach", "TenLoai", "TenKhoan" },
new object[] { LoaiThongTri, TitleThongTri, TenDonVi, NamKeHoach, TenLoai, TenKhoan });
Table table = new Table(doc);
doc.FirstSection.Body.AppendChild(table);
Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc);
table.AppendChild(row);
Aspose.Words.Tables.Cell cell = new Aspose.Words.Tables.Cell(doc);
cell.AppendChild(new Paragraph(doc));
cell.FirstParagraph.AppendChild(new Run(doc, "Mục"));
row.AppendChild(cell);
row.AppendChild(cell.Clone(false));
row.LastCell.AppendChild(new Paragraph(doc));
row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Tiểu mục"));
row.AppendChild(cell.Clone(false));
row.LastCell.AppendChild(new Paragraph(doc));
row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Tiết mục"));
row.AppendChild(cell.Clone(false));
row.LastCell.AppendChild(new Paragraph(doc));
row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Ngành"));
row.AppendChild(cell.Clone(false));
row.LastCell.AppendChild(new Paragraph(doc));
row.LastCell.FirstParagraph.AppendChild(new Run(doc, "NỘI DUNG"));
row.AppendChild(cell.Clone(false));
row.LastCell.AppendChild(new Paragraph(doc));
row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Số tiền"));
foreach (var item in Source)
{
Aspose.Words.Tables.Row row_ = new Aspose.Words.Tables.Row(doc);
table.AppendChild(row_);
Aspose.Words.Tables.Cell cell_ = new Aspose.Words.Tables.Cell(doc);
cell_.AppendChild(new Paragraph(doc));
cell_.FirstParagraph.AppendChild(new Run(doc, item.MaMuc));
row_.AppendChild(cell_);
row_.AppendChild(cell_.Clone(false));
row_.LastCell.AppendChild(new Paragraph(doc));
row_.LastCell.FirstParagraph.AppendChild(new Run(doc, item.MaTieuMuc));
row_.AppendChild(cell_.Clone(false));
row_.LastCell.AppendChild(new Paragraph(doc));
row_.LastCell.FirstParagraph.AppendChild(new Run(doc, item.MaTietMuc));
row_.AppendChild(cell_.Clone(false));
row_.LastCell.AppendChild(new Paragraph(doc));
row_.LastCell.FirstParagraph.AppendChild(new Run(doc, item.MaNganh));
row_.AppendChild(cell_.Clone(false));
row_.LastCell.AppendChild(new Paragraph(doc));
row_.LastCell.FirstParagraph.AppendChild(new Run(doc, item.TenNoiDung));
row_.AppendChild(cell_.Clone(false));
row_.LastCell.AppendChild(new Paragraph(doc));
row_.LastCell.FirstParagraph.AppendChild(new Run(doc, item.SoTien.ToString()));
}