从数据网格视图创建邮件合并。 [英] Creating Mail Merge from Data Grid View.

查看:82
本文介绍了从数据网格视图创建邮件合并。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我创建了一个datagridView,列名为First Name,姓氏,地址行1,地址行3,Address Lien 4. br />


我正在努力将其导出到Word文档。邮件合并字段是列标题。



我如何循环遍历每个单元格然后创建邮件合并文档?

解决方案

您正在询问如何遍历数据网格视图,然后使用每个网格视图行值执行邮件合并。



逐个读取datagridview行< br $> b $ b

  foreach (DataGridViewRow row  in  dataGridView1.Rows)
{
string myValue1 =( string )row.Cells [ColumnIndex1]。价值;
string myValue2 =( string )row.Cells [ColumnIndex2] .Value;
}





要使用MsWord邮件合并功能,您必须通过将MsWord库包含到项目中来执行文字自动化。按照以下链接,了解如何执行文字自动化和邮件合并



http ://support.microsoft.com/kb/301659 [ ^


Hi All ,

I have Created a datagridView with the Column Names First Name , Last Name , Address Line 1 , Address Line Three , Address Lien 4.

I am struggling to export this to a Word Document .The Mail Merge fields are the column titles.

How would I go about looping through each cell to then create a mail merge document?

解决方案

You are asking about how to loop through the datagrid view and then using the each grid view row value perform the mail merge.

to read the datagridview rows one by one

foreach(DataGridViewRow row in dataGridView1.Rows)
{
    string myValue1 = (string)row.Cells[ColumnIndex1].Value;
    string myValue2 = (string)row.Cells[ColumnIndex2].Value;
}



To use the MsWord mail merge feature you must perform word automation by including the MsWord library into your project. follow the below link on how to perform word automation and mail merge

http://support.microsoft.com/kb/301659[^]


这篇关于从数据网格视图创建邮件合并。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆