如何利用C#在WORD中插入一个5列3行的表格 程序中需要用代码新建一个word的文档,并要在文档的合适位置插入一个5列3行的表格,目前可以实现创建word的功能,但不知道如何插入表格,希望各位大哥帮帮忙,指点一下. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string strFileName = "d:\\test\\test.doc"; Object str = strFileName; Word.ApplicationClass WordApp = new Word.ApplicationClass(); WordApp.Visible = false; Word.Document WordDoc = null; try { Object o = Type.Missing; WordDoc = WordApp.Documents.Open(ref str,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o); //WordDoc.Content.Delete(ref o,ref o); WordDoc.Paragraphs.Last.Range.Text = "leiting"; Word.Range range = WordDoc.Range(ref o,ref o); WordDoc.Tables .Add(range,5,3,ref o,ref o); Word.Table WordTab = WordDoc.Tables.Item(1); WordTab.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent); WordTab.Range.Rows .Alignment = Word.WdRowAlignment.wdAlignRowCenter; //range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; WordTab.Range.Cells.Height = 25; //WordTab.Range.Cells.Width = 100; WordTab.Range.Font.Size = 12; WordTab.Range.Font.Name = "宋体"; WordTab.Range.Font.Bold = 3; //string i = WordTab.Range.Font.Bold.ToString(); } C#写的仿照Windows资源管理器的小程序(含代码) 发一个自己写的数学计算小游戏 C# winform 软件更新或者打补丁的问题 最后的分数了,全给了,望大家帮忙 誰有WM_PAINT,HOOK的例子? 高手貼出相關思路也可,謝謝 滚动显示 c# 派生类中的重载问题 帮忙解决下图片滚动问题jquery做的有链接 DataGrid的子行编辑,小白看帖不灵系列,求大哥帮助~!!! 百思不得的关于datagrid的问题 求将access数据库的表复制到sqlite数据库的表的sql语句
Object str = strFileName; Word.ApplicationClass WordApp = new Word.ApplicationClass();
WordApp.Visible = false;
Word.Document WordDoc = null;
try
{
Object o = Type.Missing;
WordDoc = WordApp.Documents.Open(ref str,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o);
//WordDoc.Content.Delete(ref o,ref o);
WordDoc.Paragraphs.Last.Range.Text = "leiting";
Word.Range range = WordDoc.Range(ref o,ref o);
WordDoc.Tables .Add(range,5,3,ref o,ref o);
Word.Table WordTab = WordDoc.Tables.Item(1);
WordTab.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
WordTab.Range.Rows .Alignment = Word.WdRowAlignment.wdAlignRowCenter;
//range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordTab.Range.Cells.Height = 25;
//WordTab.Range.Cells.Width = 100;
WordTab.Range.Font.Size = 12;
WordTab.Range.Font.Name = "宋体";
WordTab.Range.Font.Bold = 3;
//string i = WordTab.Range.Font.Bold.ToString();
}