当前上下文中不存在名称“COM”
我用的是vs2010,以前用的函数
添加引用using Excel;
以前用着没问题 现在到别的工程里用的,就报错 当前上下文中不存在名称“COM”还有 错误 1 未能找到类型或命名空间名称“COM”(是否缺少 using 指令或程序集引用?)
这是为什吗 ?两个用的都是frame4.0 请高手指教!!
public string DataExcel(System.Data.DataTable dt, string strTitle, string FilePath, Hashtable nameList)
{
//dgv.DataSource as System.Data.DataTable;
COM.Excel.cExcelFile excel = new COM.Excel.cExcelFile();
ClearFile(FilePath);
string filename = "[" + DateTime.Now.ToString("yyyy-MM-dd") + "]" + ".xls";
excel.CreateFile(FilePath + filename);
excel.PrintGridLines = false;
COM.Excel.cExcelFile.MarginTypes mt1 = COM.Excel.cExcelFile.MarginTypes.xlsTopMargin;
COM.Excel.cExcelFile.MarginTypes mt2 = COM.Excel.cExcelFile.MarginTypes.xlsLeftMargin;
COM.Excel.cExcelFile.MarginTypes mt3 = COM.Excel.cExcelFile.MarginTypes.xlsRightMargin;
COM.Excel.cExcelFile.MarginTypes mt4 = COM.Excel.cExcelFile.MarginTypes.xlsBottomMargin;
double height = 1.5;
excel.SetMargin(ref mt1, ref height);
excel.SetMargin(ref mt2, ref height);
excel.SetMargin(ref mt3, ref height);
excel.SetMargin(ref mt4, ref height);
COM.Excel.cExcelFile.FontFormatting ff = COM.Excel.cExcelFile.FontFormatting.xlsNoFormat;
string font = "宋体";
short fontsize = 9;
excel.SetFont(ref font, ref fontsize, ref ff);
byte b1 = 1,
b2 = 12;
short s3 = 12;
excel.SetColumnWidth(ref b1, ref b2, ref s3);
string header = "页眉";
string footer = "页脚";
excel.SetHeader(ref header);
excel.SetFooter(ref footer);
COM.Excel.cExcelFile.ValueTypes vt = COM.Excel.cExcelFile.ValueTypes.xlsText;
COM.Excel.cExcelFile.CellFont cf = COM.Excel.cExcelFile.CellFont.xlsFont0;
COM.Excel.cExcelFile.CellAlignment ca = COM.Excel.cExcelFile.CellAlignment.xlsCentreAlign;
COM.Excel.cExcelFile.CellHiddenLocked chl = COM.Excel.cExcelFile.CellHiddenLocked.xlsNormal;
……
……]}添加引用using Excel;
以前用着没问题 现在到别的工程里用的,就报错 当前上下文中不存在名称“COM”还有 错误 1 未能找到类型或命名空间名称“COM”(是否缺少 using 指令或程序集引用?)
这是为什吗 ?两个用的都是frame4.0 请高手指教!!
...全文
相关推荐
CLR无法从COM 上下文0x645e18 转换为COM上下文0x645f88
这个问题的描述表明,存在一个线程尝试在两个不同的COM上下文之间进行切换,但这个过程在60秒内没有完成,可能是因为某个线程被阻塞或者正在进行长时间无消息循环的操作。
springBoot 打war包 程序包com.sun.istack.internal不存在的问题及解决方案
本文主要探讨了在使用SpringBoot打包WAR时遇到com.sun.istack.internal包不存在的问题以及解决方案。
Maven install 报错"程序包不存在"问题的解决方法
Maven install 报错"程序包不存在"问题的解决方法Maven install 报错"程序包不存在"问题是 Maven 项目开发中常见的问题之一。
RottenTomatoes.com上下文菜单「RottenTomatoes.com Context Menu」-crx插件
这个扩展添加了一个上下文菜单,它提供了简单的烂番茄搜索访问。此扩展程序将新项目添加到所选文本的上下文菜单中。点击后,它会打开一个新标签并在rottentomatoes.com上搜索选定的字符串。这不是
解决Centos8 出现 配置: failovermethod “OptionBinding 不存在” 误错
在使用阿里云服务时,您可能会遇到在CentOS 8.4系统上执行`yum install git`时出现的错误,提示“配置:ID为'failovermethod'的OptionBinding不存在”。


