Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误:表格可以';t在Interop.Excel c中与另一个表重叠#_C#_Excel_Interop_Office Interop_Excel Interop - Fatal编程技术网

C# 错误:表格可以';t在Interop.Excel c中与另一个表重叠#

C# 错误:表格可以';t在Interop.Excel c中与另一个表重叠#,c#,excel,interop,office-interop,excel-interop,C#,Excel,Interop,Office Interop,Excel Interop,我收到错误一个表不能与另一个表重叠 我试着在写了几行之后,写一个相同的时间格式表。表格格式是for循环的一部分 方法1: Range range = (Range)sheet.Range[sheet.Cells[fromRow, fromCol], sheet.Cells[toRow, toCol]]; ListObject x = sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, range, Missing.Value, X

我收到错误
一个表不能与另一个表重叠

我试着在写了几行之后,写一个相同的时间格式表。表格格式是for循环的一部分

方法1:

Range range = (Range)sheet.Range[sheet.Cells[fromRow, fromCol], sheet.Cells[toRow, toCol]];
ListObject x = sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, range, Missing.Value, XlYesNoGuess.xlYes, Missing.Value);
x.TableStyle = "TableStyleMedium9";
string r = GetExcelRangeName(fromRow, fromCol, toRow, toCol);
Range range = (Range)sheet.get_Range(r);
ListObject x = sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, range, Missing.Value, XlYesNoGuess.xlYes, Missing.Value);
x.TableStyle = "TableStyleMedium9";
迭代1:通过

fromRow = 3, fromCol = 2, toRow = 187, toCol = 8 // Passed
r = "B3:H187" // Passed
迭代2:失败

fromRow = 189, fromCol = 2, toRow = 271, toCol = 8 // Failed
r = "B189:H271" //Failed
方法2:

Range range = (Range)sheet.Range[sheet.Cells[fromRow, fromCol], sheet.Cells[toRow, toCol]];
ListObject x = sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, range, Missing.Value, XlYesNoGuess.xlYes, Missing.Value);
x.TableStyle = "TableStyleMedium9";
string r = GetExcelRangeName(fromRow, fromCol, toRow, toCol);
Range range = (Range)sheet.get_Range(r);
ListObject x = sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, range, Missing.Value, XlYesNoGuess.xlYes, Missing.Value);
x.TableStyle = "TableStyleMedium9";
迭代1:通过

fromRow = 3, fromCol = 2, toRow = 187, toCol = 8 // Passed
r = "B3:H187" // Passed
迭代2:失败

fromRow = 189, fromCol = 2, toRow = 271, toCol = 8 // Failed
r = "B189:H271" //Failed

这很难调试。请提供帮助。

在第二次迭代中执行第行时出错
ListObject x=sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange,range,Missing.Value,XlYesNoGuess.xlYes,Missing.Value)即使我每次在调试时都通过
.Name
属性给出唯一的名称,仍然面临相同的问题。如果我给出
toRow-1
,则其工作正常,但当然会保留所有表中的最后一行。如何才能
“B3:H187”
“B189:H271”
overlap?在第二次迭代中执行第行时出错
ListObject x=sheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange,range,Missing.Value,XlYesNoGuess.xlYes,Missing.Value)即使我每次在调试时都通过
.Name
属性给出唯一的名称,仍然面临相同的问题。如果我给出
toRow-1
,则其工作正常,但当然会保留所有表中的最后一行。
“B3:H187”
“B189:H271”
如何重叠?