我想使用vsto将值插入excel单元格中,我在用户控制按钮上编写代码,但是它给出了错误 [英] I want to insert values into excel cell using vsto I write code on user control button but it is giving error

查看:128
本文介绍了我想使用vsto将值插入excel单元格中,我在用户控制按钮上编写代码,但是它给出了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want to insert values into excel cell using vsto I write code on user control button but it is giving error



我尝试过的事情:



What I have tried:

private void btnGetExcl_Click(object sender, EventArgs e)
       {





Excel.Worksheet activeSheet = ((Excel.Worksheet)Application.ActiveSheet);
                      activeSheet.Cells[0, 0] = text;



}



}

here for

Application

的地方出现错误

a

it is giving Error

a

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0104	''Application'' is an ambiguous reference between ''Microsoft.Office.Interop.Excel.Application'' and ''System.Windows.Forms.Application''	ExcelAddIn1	D:\VSTO_Vinayak\ExcelAddIn1\ExcelAddIn1\UserControl1.cs	213	Active

推荐答案

编译器无法确定您要使用哪个Application对象,因此必须指定完全限定的名称空间.尝试这种方式:

The compiler cannot determine which Application object you want to use, so you have to specify the fully qualified namespace. Try it this way:

Excel.Worksheet activeSheet = ((Excel.Worksheet)(Microsoft.Office.Interop.Excel.Application.ActiveSheet));



了解如何使用Google.您可以轻松找到问题的答案,并且比在论坛上提问并等待合适的答案要快.我之所以这样说是因为我厌倦了回答您的问题.我之所以这样说,是因为调试和使用Google是您可以用来更快地开发代码的两项最重要的技能.



Learn how to use google. Answers to your questions can be easily found, and is faster than asking a question on a forum, and waiting for a suitable answer. I''m not saying this because I''m tired of answering your questions. I''m saying this because debugging and using google are the two MOST important skills you can use to develop your code faster.


这篇关于我想使用vsto将值插入excel单元格中,我在用户控制按钮上编写代码,但是它给出了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆