返回信息流c#中怎样操作excel中的控件呢,比如复选框等等?
谢啦先~~
这是一条镜像帖。来源:北邮人论坛 / dot-net / #1422同步于 2010/3/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
dotNET机器人发帖
请教如何用C#操作excel文件中的控件
sophia77
2010/3/25镜像同步7 回复
订阅后,新回复会通过你的通知中心匿名送达。
7 条回复
我的程序:
//打开现有的excel
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
Workbook bk = excel.Application.Workbooks.Open("D:\\example.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
//打开sheet
Worksheet ws = (Worksheet)bk.Worksheets.get_Item(3);
try
{
Microsoft.Office.Interop.Excel.Label lb = ws.Labels(2) as Microsoft.Office.Interop.Excel.Label;
MessageBox.Show(lb.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.TargetSite.ToString());
}
finally
{
//释放资源
bk.Close(true, null, null);
excel.Quit();
releaseObject(ws);
releaseObject(bk);
releaseObject(excel);
}
}
----------------------------------------------------------------------------------
运行提示:异常来自 hresult 0x800a03ec
---------------------------------------------------------------------------------
提示下面这句处有问题:
Microsoft.Office.Interop.Excel.Label lb = ws.Labels(2) as Microsoft.Office.Interop.Excel.Label;
as 这半句价格括号吧
【 在 sophia77 (七七) 的大作中提到: 】
: 我的程序:
: //打开现有的excel
: Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
: ...................
恩,这段代码是找的网上的。可是也有人反应有我这样的问题啊。哪儿出了问题呢?
【 在 KilltheThree 的大作中提到: 】
: 运行了一下,没有遇到lz说的异常啊。。。