我有一个有趣的问题,由于重写了我的导出,我遇到了一些麻烦。使用下面的代码,我尝试在我的 Excel 工作簿中填充拆分范围。结果真的很奇怪,范围( tpl_p1 )的第一部分填充正确,但第二部分填充非常奇怪,请参见屏幕截图。
openExcel(@"C:\bla\test.xlsx", "Tabelle1");
ArrayList posData = new ArrayList();
int lines = 30;
string[,] fo = new string[lines, 7];
for (int a = 0; a < lines; a++)
{
fo[a, 0] = "1";
fo[a, 1] = "2";
fo[a, 2] = "3";
fo[a, 3] = "4";
fo[a, 4] = "5";
fo[a, 5] = "6";
fo[a, 6] = "7";
}
int i = 0;
object rng;
object[] rgums = new Object[1]; // { "A1:C70","E1:H70" };
object[] argums = new Object[1];
rgums[0] = "tpl_p1;tpl_p2";
try
{
rng = Sheet.GetType().InvokeMember("Range", System.Reflection.BindingFlags.GetProperty, null, Sheet, rgums);
argums[0] = 1;
rng.GetType().InvokeMember("Select", System.Reflection.BindingFlags.InvokeMethod, null, rng, null);
argums[0] = fo;
rng.GetType().InvokeMember("Value", System.Reflection.BindingFlags.SetProperty, null, rng, argums);
}
catch (Exception ex)
{
createErrorReport(ex, "Com");
}
这里是 Excel 中的结果: 结果
我不明白为什么数组在 Range 的第二部分被破坏。