无法将类型为:“Microsoft.office.interop.Excel.applicatio 5
无法将类型为:“Microsoft.office.interop.Excel.applicatio无法将类型为:“Microsoft.office.interop.Exc...
无法将类型为:“Microsoft.office.interop.Excel.applicatio无法将类型为:“Microsoft.office.interop.Excel.application.class”对象强制转换为接口类型,怎么解决呢!图片无法翻转,将就着看吧。。。
展开
1个回答
2016-10-03
展开全部
=前面的定义全部改成dynamic就可以了,问题是解决了,不过后面没有智能提示,写代码不方便。
参考代码:
dynamic xls = new msxls.Application();
var m = System.Reflection.Missing.Value;
dynamic book = xls.Workbooks.Open(filePath);//, m, m, m, m, m, m, m, m, m, m, m, m, m, m);
string source, result;
int curRow = 0, curColumn = 0;
NameValueList<string> varList = new NameValueList<string>(ScriptReader.NullNameParameter);
try
{
foreach (dynamic sheet in book.Sheets)
{
var r = sheet.Cells.SpecialCells(msxls.XlCellType.xlCellTypeLastCell, m);
for (int row = 1; row <= r.Cells.Row; row++)
{
curRow = row;
for (int column = 1; column <= r.Cells.Column; column++)
{
curColumn = column;
source = (sheet.Cells[row, column]).Formula as string;
参考代码:
dynamic xls = new msxls.Application();
var m = System.Reflection.Missing.Value;
dynamic book = xls.Workbooks.Open(filePath);//, m, m, m, m, m, m, m, m, m, m, m, m, m, m);
string source, result;
int curRow = 0, curColumn = 0;
NameValueList<string> varList = new NameValueList<string>(ScriptReader.NullNameParameter);
try
{
foreach (dynamic sheet in book.Sheets)
{
var r = sheet.Cells.SpecialCells(msxls.XlCellType.xlCellTypeLastCell, m);
for (int row = 1; row <= r.Cells.Row; row++)
{
curRow = row;
for (int column = 1; column <= r.Cells.Column; column++)
{
curColumn = column;
source = (sheet.Cells[row, column]).Formula as string;
追问
你好,我是程序小白,这是我们工作上需要的一个工作软件。软件在最后导出Excel表格的时候出现这个错误的,能告知下具体操作吗?万分感谢☺
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询