用visual C++ 2008 速成版编写EXCEL程序--测试托管程序调用COM组件
2009-01-08 21:03
423 查看
一、新建一个CLR控制台项目
二、到项目属性的->通用属性->框架和引用里,添加新引用,选择COM,找到EXCEL和OFFICE引用,添加进来:
//-----------------------------------------------------------------------
// This file is part of the Microsoft .NET SDK Code Samples.
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//This source code is intended only as a supplement to Microsoft
//Development Tools and/or on-line documentation. See these other
//materials for detailed information regarding Microsoft code samples.
//
//THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//-----------------------------------------------------------------------
#include "stdafx.h"
using namespace System;
using namespace System::Reflection; // For Missing.Value and BindingFlags
using namespace System::Runtime::InteropServices; // For COMException
using namespace Microsoft::Office::Core;
using namespace Microsoft::Office::Interop::Excel;
二、到项目属性的->通用属性->框架和引用里,添加新引用,选择COM,找到EXCEL和OFFICE引用,添加进来:
//-----------------------------------------------------------------------
// This file is part of the Microsoft .NET SDK Code Samples.
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//This source code is intended only as a supplement to Microsoft
//Development Tools and/or on-line documentation. See these other
//materials for detailed information regarding Microsoft code samples.
//
//THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//-----------------------------------------------------------------------
#include "stdafx.h"
using namespace System;
using namespace System::Reflection; // For Missing.Value and BindingFlags
using namespace System::Runtime::InteropServices; // For COMException
using namespace Microsoft::Office::Core;
using namespace Microsoft::Office::Interop::Excel;
相关文章推荐
- C#如何编写调用COM组件的程序
- [转]在Windows Server 2008 X64中通过.NET程序调用32位com组件
- 在Windows Server 2008 X64中通过.NET程序调用32位com组件
- 在Windows Server 2008 X64中通过.NET程序调用32位com组件
- SilverLight OOB模式与Com API交换的基础 和 C#编写Com 组件在SilverLight调用
- 将调用密集型的 COM 组件迁移到托管代码
- 检索 COM 类工厂中 CLSID 为{00024500-0000-0000-C000-000000000046} 的组件(程序架到IIS上后,Excel导出报错问题)
- VC6.0和VS2005:C++和C#编写调用COM组件
- PHP4调用自己编写的COM组件
- PHP4 调用自己编写的 COM 组件
- Visual C++ 2008入门经典 第13章 使用MFC编写Windows程序
- 解决64位windows server 2008上调用Excel组件出现0x800A03EC错误
- 1)编写Animal接口,接口中声明run()方法; 2)定义Bird类和Fish类实现Animal接口; 3)编写Bird类和Fish类的测试程序,并调用其中的run()方法
- 1)编写Animal接口,接口中声明run()方法; 2)定义Bird类和Fish类实现Animal接口; 3)编写Bird类和Fish类的测试程序,并调用其中的run()方法
- 1)编写Animal接口,接口中声明run()方法; 2)定义Bird类和Fish类实现Animal接口; 3)编写Bird类和Fish类的测试程序,并调用其中的run()方法
- JavaScript学习笔记之JavaScript调用C#编写的COM组件
- 1)编写Animal接口,接口中声明run()方法; 2)定义Bird类和Fish类实现Animal接口; 3)编写Bird类和Fish类的测试程序,并调用其中的run()方法
- 调试Excel调用的COM组件
- 使用.NET2.0编写COM组件供VB调用
- asp.net 程序里面调用了excel组件,权限解决方案