导航
  • 主页
  • VC综合技术
  • 互联网技术
  • MFC AppLauncher
  • .NET 技术
  • 界面
  • 进程
  • 算法
  • 硬件/系统
  • 数据库
  • VC++技术资源

我想用VC开发Excel的程序,大家给点建议,好的建议都有分!!!

sonyge 2004-04-09 07:47:48
我有几个问题,用VC开发Excel是否一定要在用户机器上安装Excel.
有那些网站有好的VC++开发Eccel资料.
谁有例子程序,我想要几个,我的邮箱是 WJQ@obton.com 谢谢
...全文
56 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
1HelloWorld 2004-04-10
MSDN上就有详细的例子
回复
masterz 2004-04-10
http://www.fruitfruit.com/vc/activex/excelauto.cpp
回复
supercwj 2004-04-10
gz
回复
zhangcrony 2004-04-09
.....................

http://www.codeproject.com/database/cspreadsheet.asp?target=excel
回复
zhangcrony 2004-04-09
There are times when we wish to send our output to an Excel file or some text delimited files like comma separated value file or tab delimited file. This class encapsulates the functions for reading and writing to these types of files. It was constructed with a goal of being simple to use. The main features of this class are:

Constructing a new Excel or text delimited file and writing rows or a single cell to it.
Reading rows, columns or a single cell from an Excel or text delimited file.
Replacing, inserting or appending rows to an Excel or text delimited file.
Convert an existing or newly created Excel to text delimited file and vice versa
Before I describe the various functions of the class, I will first state the limitations of this class. The limitations are:

Requires MFC.
May or may not support unicode. (didn't check it out)
Uses ODBC to read and write to Excel file, thus will have the limitations of ODBC driver. (I am not sure whatever limitation does the ODBC driver has)
Must have header row in Excel file and every column of the header row must be unique. (because class is treating Excel file as a database)
Cannot delete a sheet from Excel file. Can only delete contents of that sheet
Cell values are treated as a string, regardless of their format in Excel.
I have inserted error checking code whenever possible but I may have missed out some cases. Thus the user is required to keep the limitations in mind to prevent unexpected errors.

Below is a detailed description of the class. It is split into two parts. The first part is for those who just wish to know how to use the class. It contains a brief description of all the useful functions and how to use them. It is followed by an example that demonstrates most of the functions in the class.

The second part is for those who wish to know all the functions and variables of the class in detail. That section will describe how the function works, what are the limitations and possible errors, and how the functions, after many revisions, came to their final form. This will be useful to those who intends to change the class to suit their needs.

Now, prepare yourself for a long article ahead..

Part I. How to use the class
The following is an overview of the useful functions in the class, organised by whether they are common to both Excel and text delimited spreadsheet or only to one of them

Common Functions
CSpreadSheet(CString File, CString SheetOrSeparator, bool Backup = true)
bool AddHeaders(CStringArray &FieldNames, bool replace = false)
bool AddRow(CStringArray &RowValues, long row = 0, bool replace = false)
bool AddCell(CString CellValue, short column, long row = 0)
bool AddCell(CString CellValue, CString column, long row = 0, bool Auto = true)
bool ReadRow(CStringArray &RowValues, long row = 0)
bool ReadColumn(CStringArray &ColumnValues, short column)
bool ReadColumn(CStringArray &ColumnValues, CString column, bool Auto = true)
bool ReadCell (CString &CellValue, short column, long row = 0)
bool ReadCell (CString &CellValue, CString column, long row = 0, bool Auto = true)
bool DeleteSheet()
bool DeleteSheet(CString SheetName)
bool Convert(CString SheetOrSeparator)
void BeginTransaction()
bool Commit()
bool RollBack()
bool GetTransactionStatus()
void GetFieldNames (CStringArray &FieldNames)
long GetTotalRows()
short GetTotalColumns()
long GetCurrentRow()
bool GetBackupStatus()
CString GetLastError()
Excel Spreadsheet Specific Functions
bool ReplaceRows(CStringArray &NewRowValues, CStringArray &OldRowValues)
Text Delimited Spreadsheet Specific Functions
None

Common Functions
CSpreadSheet(CString File, CString SheetOrSeparator, bool Backup = true)

This constructor will open an Excel file (xls) or a text delimited file (any other file extensions e.g. csv, tab) for reading (for existing file) or writing (for new file or existing file). The variable SheetOrSeparator is the name of the sheet if the file is an Excel file or the type of separator if the file is a text delimited file. The default constructor will create a backup file (.bak for text delimited file) or a backup sheet (named CSpreadSheetBackup for Excel file) if opening an existing file.

回复
_foo 2004-04-09
我有几个问题,用VC开发Excel是否一定要在用户机器上安装Excel.
/////////////////////
re:那是肯定的。




有那些网站有好的VC++开发Eccel资料.
谁有例子程序,我想要几个,我的邮箱是 WJQ@obton.com 谢谢
/////////////////////////////////////////////////////////

re:

http://www.vckbase.com/document/listdoc.asp?mclsid=17&sclsid=1713

其实很简单的,知道了怎么调用后,剩下就是熟悉excel的对象模型参考了(msdn中有)
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……