如何使用C#在Windows Word中制作表格的副本 [英] How to make a copy of a table in windows word using C#

查看:85
本文介绍了如何使用C#在Windows Word中制作表格的副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想使用C#在寡妇字中复制现有表格.任何想法?


谢谢!
Soumya

Hi,
I would like to make a copy of an existing table in widows word using C#.Any ideas??


Thanks!
Soumya

推荐答案

以下C#代码将帮助您使用Office interop assebly复制现有表:

Below C# code will help you to copy the existing table using Office interop assebly:

using Microsoft.Office.Interop.Word;

Word.Range range = table.Range; 
range.Copy();  

Word.Range rng = table.Range; 
rng.SetRange(table.Range.End, table.Range.End);  

Word.Table tableCopy = document.Tables.Add(rng, 1, 1, ref missing, ref missing); 
tableCopy.Range.Paste();  


//docTable是表1
//tableCopy是表2,它是表1的副本

范围范围= docTable.Range;
range.Copy();
range.SetRange(docTable.Range.End +1,docTable.Range.End +1);

表格tableCopy = doc.Tables.Add(rng,1,1,缺少参考,缺少参考);
tableCopy.Range.Paste();
// docTable is the Table 1
// tableCopy is the Table 2 which is the Replica of Table 1

Range range = docTable.Range;
range.Copy();
range.SetRange(docTable.Range.End + 1, docTable.Range.End + 1);

Table tableCopy = doc.Tables.Add(rng, 1, 1, ref missing, ref missing);
tableCopy.Range.Paste();


这篇关于如何使用C#在Windows Word中制作表格的副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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