public static void OnCreateReportUsingFieldMergeCell(IWin32Window owner, string reportTitle, List <Hashtable> listSource, Hashtable fieldParams, Hashtable bookMarkParams, string reportName, string templateDir, Hashtable mapMergeCell, bool includeSumRow, bool isItalicHeader, bool autoIndex, string prefixParam, string posfixParam) { string tempFile; bool returnCode = UpdateTempFile(owner, templateDir, reportName, out tempFile); if (!returnCode) { return; } try { WordAppUtil.ThreadForWaitingExport(); // tao wordApp tu template WordAppUtil.CreateMsWordFromTemplate(); UpdateTableData(listSource, autoIndex, includeSumRow, isItalicHeader); DoMergeCell(mapMergeCell); UpdateParamUsingMergeField(fieldParams, prefixParam, posfixParam); UpdateParamUsingBookmark(bookMarkParams); } finally { WordAppUtil.QuitMsWordApp(true); WordAppUtil.ThreadForClosingExport(); } WordViewerUtil.LoadDocument(owner, reportTitle, tempFile, true); }
public static void OnCreateReportUsingBookmark(IWin32Window owner, string reportTitle, List <Hashtable> listSource, Hashtable mapParams, string reportName, string templateDir, bool includeSumRow, bool autoIndex) { string tempFile; bool returnCode = UpdateTempFile(owner, templateDir, reportName, out tempFile); if (!returnCode) { return; } try { WordAppUtil.ThreadForWaitingExport(); // tao wordApp tu template WordAppUtil.CreateMsWordFromTemplate(); UpdateTableData(listSource, autoIndex, includeSumRow, false); UpdateParamUsingBookmark(mapParams); } finally { WordAppUtil.QuitMsWordApp(true); WordAppUtil.ThreadForClosingExport(); } WordViewerUtil.LoadDocument(owner, reportTitle, tempFile, true); }
private void button3_Click(object sender, EventArgs e) { // path of template *.dot WordAppUtil.Template = Application.StartupPath + "/" + "test.dot"; WordAppUtil.ThreadForWaitingExport(); // tao wordApp tu template WordAppUtil.CreateMsWordFromTemplate(); // thiet lap du lieu table nguon cho WordDoc Table WordAppUtil.SourceTable = _dataTable; WordAppUtil.ColumnNames = new List <string>() { "id", "ten", "chuc_vu", "phong_ban_id" }; // fill du lieu vao WordDoc Table WordAppUtil.FillDataToWordDocTable2(1, false, true); // thiet lap cac parameter cho WordDoc WordAppUtil.SetParameterUsingBookmark("hinh_thuc_cung_cap", " Truc tiep"); WordAppUtil.SetParameterUsingBookmark("hinh_thuc_cung_cap1", " Truc tiep1"); WordAppUtil.SetParameterUsingBookmark("tu_ngay", "Từ ngày 12/06/2013 - đến ngày 12/07/2013"); WordAppUtil.SetParameterUsingBookmark("ngay_in", "Hà nội, ngày 12 tháng 07 năm 2013"); WordAppUtil.SetParameterUsingBookmark("nguoi_lap", "Chung Duy Nguyễn"); string tempFile = Application.StartupPath + "/test_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".doc"; WordAppUtil.SaveAs(tempFile); WordAppUtil.QuitMsWordApp(false); WordAppUtil.OpenWordDocument(tempFile); WordAppUtil.ThreadForClosingExport(); }