C++操作Excel学习笔记(四)

本文详细介绍了C++操作Excel的核心对象,包括Application、Workbook、Worksheet和Range对象,以及如何启动和退出Excel,加载文本文件,获取行数,生成图表并设置格式。还探讨了命名空间在解决不同对象名冲突中的应用。
摘要由CSDN通过智能技术生成
【当前博文转载自 http://blog.csdn.net/sgdgoodboy/article/details/2102628】
【本文前半部分与word相关,发在 C++操作Word学习笔记(三)

EXCEL篇及命名空间说明

1 Excel组件对象模型    
Microsoft Office Excel 2003文档中的数据是高度结构化的,因此Excel对象模型也具有层次结构并且简单明了。Excel 提供了数百个您可能需要与之交互的对象,但是最为重要的是以下四个对象:Application 对象、Workbook 对象、Worksheet 对象和Range 对象。很多工作都是围绕这四个对象进行的。
Application 对象。Application 对象表示 Excel 应用程序本身。Application 对象提供了大量有关正在运行的应用程序、应用于该实例的选项以及在该实例中打开的当前用户的对象的信息。
Workbook 对象。Workbook 类表示 Excel 应用程序内的单个工作簿。Application 类的许多成员同时也是 Workbook 类的成员。在这种情况下,属性应用于特定的工作簿(而非应用于活动工作簿)。
Worksheet 对象。虽然 Worksheet 类提供了大量成员,但大部分属性、方法和事件都与 Application

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是曾经做过的一个项目时写的一个动态库,用c++操作Excel,包括以下功能: //===================================mainly function============================ //FuncName: xls_create //function: create excel server //return value: return 1 if success, otherwise 0 _export bool xls_create(); //FuncName: xls_new_file/xls_new_file2 //function: create an excel file (from a template) //parameter: strTemplate ->excel template file name,eg: "template.xlt" or "d:\teplate.xls" // strFileName ->the file name used to save excel file as,eg: "Temp.xls" // openfile ->1: open excel file after writen it,otherwize don't open it //return value: return the excel fileID which created from template, between 1 and 256 if success, or zero otherwise _export int xls_new_file(char* szTemplate, char* szFileName, int openfile); _export int xls_new_file2(char* szFileName, int openfile); //FuncName: xls_open_file //function: Open an exist excel file //parameter:the file name will to be opened //return value: return the fileID, if open file success,otherwize return 0 _export int xls_open_file(char* szFileName); //FuncName: xls_write_xxx //function: write a double value to xls file //parameter: fileID ->the excel file ID which we will write the value into,between 1 and 256 // sheetID ->the sheet index of the excel file which we will write the value into,between 1 and 256 // crow ->the row index which we will write the value into, not less 1 // ccol ->the column index which we will write the value into, not less 1 // value ->the double value which we will write into excel //Note: if you want to input enter key in excel file,you may use \n in your str //return value: return 1 if success, otherwise 0 _export int xls_write_str(int fileID, int sheetID, int crow, int ccol, char* value); _export int xls_write_dbl(int fileID, int sheetID, int crow, int ccol, double value); _export int xls_write_int(int fileID, int sheetID, int crow, int
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值