我想从excel表中获取mergeArea单元格。代码我使用Microsoft.office.interop.excel.dll
运行程序我收到错误(0x800a03ec(-2146827284))
if (File.Exists(filename))
{
Microsoft.Office.Interop.Excel.Application variable = (Microsoft.Office.Interop.Excel.Application)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
Workbook variable1 = variable.Workbooks.Open(filename, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
Worksheet item = (Worksheet)((dynamic)variable1.Worksheets[1]);
Range usedRange = item.UsedRange;
int count = usedRange.Columns.Count;
int num = usedRange.Rows.Count;
Range mergeArea = cells.MergeArea;
答案 0 :(得分:0)
该错误代码特别意味着Excel无法找到您询问的内容;从代码片段中,我怀疑它可能就是这一行:
Worksheet item = (Worksheet)((dynamic)variable1.Worksheets[1]);
你确定文件中有多张纸吗?它实际上抛出了哪一行?