vs.net2005 中word 打印问题?

来源:百度知道 编辑:UC知道 时间:2024/06/04 12:34:11
我下载了一个c#开发的windows 应用程序,其中有一个页面涉及到word打印.具体就是把页面中许多的TextBox中的内容插入到word中的表格,部分代码如下:

private void but_Table_Click(object sender, EventArgs e)//按钮事件
{

object Nothing = System.Reflection.Missing.Value;
object missing = System.Reflection.Missing.Value;
//创建Word文档
Word.Application wordApp = new Word.ApplicationClass();
Word.Document wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordApp.Visible = true;

object missingValue = Type.Missing;
object location = strInfo.Length; //如果location超过已有字符的长度将会出错。一定要比"明细表"串多一个字符
Word.Range rng2 = wordDoc.Range(ref location, ref location);

wordDoc.Tables.Add(rng2, 14, 6, ref missingValue, ref missingValue);
wordDoc.Tables.Item(1).Rows.HeightRule = Word.WdRowHeightRule.wd

说实话你自己都不知道要输出什么
你页面上面有控件,如果你想把这个页面的数据输出到另外一个页面并且以表格形式我这里有代码可以参考。

如果你要直接输出恐怕不行,你页面上面的按钮会一起输出造成页面混乱