C# 最大行数Microsoft.Office.Interop.Word.Table
我正在尝试生成一个表并将其插入Word文档,如下所示:C# 最大行数Microsoft.Office.Interop.Word.Table,c#,ms-word,office-interop,C#,Ms Word,Office Interop,我正在尝试生成一个表并将其插入Word文档,如下所示: object missing = System.Reflection.Missing.Value; var paragraph = miDoc.Paragraphs.Add(ref missing); Microsoft.Office.Interop.Word.Table tablaEvaluacion = Globals.ThisDocument.Tables.Add(paragraph.Range, lstContacto.Coun
object missing = System.Reflection.Missing.Value;
var paragraph = miDoc.Paragraphs.Add(ref missing);
Microsoft.Office.Interop.Word.Table tablaEvaluacion =
Globals.ThisDocument.Tables.Add(paragraph.Range, lstContacto.Count + 1, lstEvaluacion.Count + 3, ref missing, ref missing);
但当行数超过63时,这会导致异常:“COMException未由用户代码处理。该数字必须介于1和63之间。
”首先-您100%确定是指行吗?正如您在下面的回答中所看到的,在表中插入超过63行没有问题,但是插入超过63列会导致与您描述的相同的问题
无论如何,我已经尝试过调查这一点——以下是我的发现:
使用谷歌:
- 这里提出了一个类似的问题:-似乎刚刚得出结论,这是Word设定的限制-但AFAIK没有确凿证据(阅读:参考任何文档)
documentA.Tables.Add(range, 01, 64); // COMException -> "The number must be between 1 and 63."
documentA.Tables.Add(range, 01, 63); // All good
documentA.Tables.Add(range, 64, 01); // All good
- 由于未提及限制,因此该限制在这里没有多大帮助
- 我尝试反编译
类型,希望找到一条描述限制的注释,但没有成功。代码只是使用Microsoft.Office.Interop.Word.Tables
在Word中包含函数,因此异常很可能从Word一直冒泡到互操作程序集,再到代码中COM
documentA.Tables.Add(range, 01, 64); // COMException -> "The number must be between 1 and 63."
documentA.Tables.Add(range, 01, 63); // All good
documentA.Tables.Add(range, 64, 01); // All good
示例代码显示,当我尝试使用超过63列时,会抛出您引用的COMException
。我正在运行MS Office 2013,附带15版互操作API btw
使用MS Word 2013:
- 首先使用我的示例应用程序插入一个包含63列的表,然后打开文档并要求Word插入另一列-这给了我以下错误:
- 这里提出了一个类似的问题:-似乎刚刚得出结论,这是Word设定的限制-但AFAIK没有确凿证据(阅读:参考任何文档)
documentA.Tables.Add(range, 01, 64); // COMException -> "The number must be between 1 and 63."
documentA.Tables.Add(range, 01, 63); // All good
documentA.Tables.Add(range, 64, 01); // All good
- 由于未提及限制,因此该限制在这里没有多大帮助
- 我尝试反编译
类型,希望找到一条描述限制的注释,但没有成功。代码只是使用Microsoft.Office.Interop.Word.Tables
在Word中包含函数,因此异常很可能从Word一直冒泡到互操作程序集,再到代码中COM
documentA.Tables.Add(range, 01, 64); // COMException -> "The number must be between 1 and 63."
documentA.Tables.Add(range, 01, 63); // All good
documentA.Tables.Add(range, 64, 01); // All good
示例代码显示,当我尝试使用超过63列时,会抛出您引用的COMException
。我正在运行MS Office 2013,附带15版互操作API btw
使用MS Word 2013:
- 首先使用我的示例应用程序插入一个包含63列的表,然后打开文档并要求Word插入另一列-这给了我以下错误: