111,126
社区成员
发帖
与我相关
我的任务
分享
public void ReplaceBookmarkText(Word.Document wordDoc, string BookmarkName, string NewText, Object style)
{
if (wordDoc.Bookmarks.Exists(BookmarkName))
{
Object name = BookmarkName;
Word.Range rng = wordDoc.Bookmarks.get_Item(ref name).Range;
rng.Text = NewText;
Object range = rng;
wordDoc.Bookmarks.Add(BookmarkName, ref range);
rng.set_Style(ref style);
}
}
:
string title = "感官\n";
obj = "一级条标题";
this.ReplaceBookmarkText(WordDoc, "SenseTitle", title, obj);
obj = "段";
this.ReplaceBookmarkText(WordDoc, "SenseContent", "将样品置于白色搪瓷盘上,在自然光和无异味环境下通过目视、鼻嗅。\n", obj);
DataTable t = DBTools.EDS("select * from TestRule where Cate='其他(感官,水分..)' and WordID=" + selectedID).Tables[0];
int count0 = t.Rows.Count;
for (int i = 0; i < count0; i++)
{
str = str + t.Rows[i][2].ToString() + t.Rows[i][3].ToString() + t.Rows[i][4].ToString()
+ "按" + t.Rows[i][5].ToString() + "的规定执行。\n";
}
obj = "一级条标题";
this.ReplaceBookmarkText(WordDoc, "NextTitle", str, obj);
DataTable t1 = DBTools.EDS("select * from TestRule where Cate='营养成份指标' and WordID=" + selectedID).Tables[0];
obj = "一级条标题";
this.ReplaceBookmarkText(WordDoc, "NuTitle", "营养成份指标\n", obj);
str = "";
int count = t1.Rows.Count;
for (int i = 0; i < count; i++)
{
str = str + " " + t1.Rows[i][2].ToString() + t1.Rows[i][3].ToString() + t1.Rows[i][4].ToString()
+ "按" + t1.Rows[i][5].ToString() + "的规定执行。\n";
}
obj = "二级条标题";
this.ReplaceBookmarkText(WordDoc, "NuContent", str, obj);
DataTable t2 = DBTools.EDS("select * from TestRule where Cate='卫生指标' and WordID=" + selectedID).Tables[0];
count = t2.Rows.Count;
str = "卫生指标\n";
obj = "一级条标题";
this.ReplaceBookmarkText(WordDoc, "HygneTitle", str, obj);
str = "";
for (int i = 0; i < count; i++)
{
str = str + "按" + t2.Rows[i][5].ToString() + "的规定执行。\n";
}
obj = "段";
this.ReplaceBookmarkText(WordDoc, "HygneContent", str, obj);
DataTable t3 = DBTools.EDS("select * from TestRule where Cate='净含量' and WordID=" + selectedID).Tables[0];
count = t3.Rows.Count;
str = "净含量\n";
obj = "一级条标题";
this.ReplaceBookmarkText(WordDoc, "ContentTitle", str, obj);
str = "";
for (int i = 0; i < count; i++)
{
str = str + "净含量的测定按" + t3.Rows[i][5].ToString() + "的规定执行。\n";
}
obj = "段";
this.ReplaceBookmarkText(WordDoc, "CContent", str, obj);