VC++操作Excel在VS2008编码实例

VC++与MFC大作业实战:从环境搭建到部署的Windows桌面开发全流程 Windows桌面应用开发是理解操作系统与图形界面编程的基础。其核心在于通过框架将系统API、消息循环与用户界面有机整合,实现高效、稳定的本地应用程序。MFC(Microsoft Foundation Classes)作为经典的C++应用程序框架,采用文档/视图架构,清晰分离数据管理与界面展示,是学习面向对象设计与框架思维的优秀范例。在工程实践中,开发者常需处理环境配置、依赖管理等实际问题,例如解决“电脑VC++库自检”失败或集成“微软VC++运行库”。掌握这些技能,不仅能完成如设备管理系统等综合应用项目, 阅读详情

这篇文章是接上一篇 VC++操作Excel在VS2008配置过程后的编码实例,详细给出了操作EXCEL的操作过程,大家可以举一反三,实现自己的功能。

gsExcel::CApplication m_ExlApp;
gsExcel::CRange m_ExlRange;
gsExcel::CWorkbook m_ExlWorkBook;
gsExcel::CWorkbooks m_ExlWorkBooks;
gsExcel::CWorksheet m_ExlWorkSheet;
gsExcel::CWorksheets m_ExlWorkSheets;
gsExcel::CRange m_ExlColor;
gsExcel::CFont0 m_ExlFont;


CString strTheAppPath;
CString strTheAppName;


TCHAR szAppPath[MAX_PATH];
GetModuleFileName(NULL, szAppPath, MAX_PATH);
strTheAppPath = CString(szAppPath);


strTheAppName = AfxGetApp()->m_pszAppName;
strTheAppName += _T(".exe");


int iLengthOne = strTheAppPath.GetLength();
int iLengthTwo = strTheAppName.GetLength();


strTheAppPath.Delete(iLengthOne - iLengthTwo, iLengthTwo);


CString strTemplatePath;


strTemplatePath += _T("TemplateOne.xlsx");
strTemplatePath = strTheAppPath + strTemplatePath;




COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);


// 启动EXCEL应用程序
if(!m_ExlApp.CreateDispatch(_T("Excel.Application")))
{
MessageBox(_T("创建Excel服务失败...."),_T("信息提示"), MB_OK);
return;
}


C++操作Excel的高级类使用教程 libxl是一个商业库,支持在C++程序中创建、读取、写入和修改Microsoft Excel文件(包括.xlsx和.xls格式)。它不依赖于Microsoft Excel或任何其他软件组件,可以直接在Windows、Linux和Mac OS X环境下运行。libxl库的设计目标是提供一个简单、强大且高效的接口,用于处理Excel文件。这使得它成为需要在C++应用程序中处理Excel数据的开发者的理想选择。 阅读详情

相关推荐

VC++中实现数据保存到Excel的详细教程

htmltable {th, td {th {pre {简介:在VC++开发环境中,通过使用Microsoft Office的自动化接口和COM技术,可以实现将数据保存到Excel文件中。这包括创建Excel实例、操作工作簿和工作表、写入数据、保存和关闭操作以及异常处理等步骤。此外,为了性能优化,还可以考虑使用Open XML SDK或第三方库如libxl、Apache POI等技术。

weixin_31938351的博客 983

VC++实现Excel读写操作示例教程

COM(Component Object Model)是一种用于构建软件组件的二进制接口标准,广泛应用于Windows平台的开发中。其核心理念是通过定义接口(Interface)实现模块化、可扩展和可重用的软件组件。COM组件通过接口暴露其功能,调用者无需了解组件内部实现细节,只需按照接口规范进行调用即可。COM技术的关键特点包括:接口驱动:所有功能通过接口暴露,接口定义了组件的公共方法和属性。跨语言支持:COM组件可以用不同语言实现,调用者也可以使用不同语言访问。

weixin_35829279的博客 1080

基于VC++的仿Excel电子表格系统开发实战

本系统采用模块化分层架构,基于MVC模式将数据模型(Model)、界面视图(View)与控制逻辑(Controller)解耦。通过C++类体系实现高内聚、低耦合的代码结构,便于后期功能扩展与维护。是MFC中用于绘制客户区内容的核心虚函数。每当窗口需要重绘(如窗口大小改变、滚动、显式调用)时,框架都会调用此函数。在电子表格中,我们必须在此函数内完成三项主要任务:绘制网格线、填充单元格内容、绘制表头与选区高亮。以下是简化的OnDraw实现框架:// 获取剪裁区域,优化绘制范围。

weixin_42601134的博客 955

VC++环境下Excel文件读写操作指南

有时候Excel的内置功能无法满足特定需求,VC++可以通过编程方式扩展Excel的功能,实现更复杂的定制操作。Microsoft Office Interop是一组为Visual Studio开发人员提供的库,它允许用户利用.NET编程语言控制Office应用程序。在VC++项目中,通过添加对Office Interop组件的引用,开发者可以利用这些组件提供的对象模型来编写代码,实现自动化Office文档的创建、修改和查询等操作。

weixin_42589700的博客 1441

MFC实现Excel读写[项目源码]

本文详细介绍了在Visual Studio 2015环境下,使用MFC框架实现对Excel文件的读写操作。首先,文章指导读者创建一个基于对话框的MFC应用程序,并确保项目正常运行。接着,通过类向导引入Excel资源类,包括_Application、_Workbook、_Worksheet等接口,并解决可能出现的编译错误。最后,文章提供了具体的代码示例,展示如何打开或创建Excel文件,读取单元格数据,并释放相关资源。整个过程涵盖了从环境配置到实际操作的完整步骤,适合需要在MFC项目中处理Excel文件的开发者参考。

MIPI D-PHYv2.5笔记(11) -- 高速时钟传输(High-Speed Clock Transmission)

在High-Speed模式中,Clock Lane提供了一个低摆幅(low-swing)、差分DDR时钟信号,此信号从Master到Slave,用于为高速数据传输提供时钟信号。时钟信号关于Forward Direction中的Data Lane上的位切换序列(toggling bit sequence)有正交相位,并且在一次burst的第一个被传输的bit的中心点有一个上升沿。

vivo01的专栏 3029

力扣(Leetcode)第1题:两数之和(C语言版本)

题目: 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出和为目标值 target 的那两个整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 示例 1: 输入:nums = [2,7,11,15], target = 9 输出:[0,1] 解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。 示例 2: 输入:nums = [3,2,4], target = 6

qq_39855356的博客 3343

数电发票“乐企直连”服务平台建设方案

数字化电子发票“乐企直连”服务平台建设方案

m0_73174802的博客 4867

PID不够用?试试给PID加上‘预言’能力:史密斯预测器(SP)在温控、液位控制中的实战配置

本文深入探讨了史密斯预测器(SP)在温控和液位控制中的应用,特别针对大滞后系统的PID控制难题。通过详细解析SP的核心组件、参数整定技巧及进阶应用FSP,结合西门子PLC的实战配置方案,帮助工程师有效提升控制精度和系统稳定性。文章还提供了S7-1200的完整实现步骤和调试技巧,为工业自动化控制提供了实用解决方案。

weixin_33686714的博客 478

OpenHarmony可信执行环境:TEE模块源码分析与实现原理

TEE(Trusted Execution Environment)是OpenHarmony系统中的安全执行环境,用于提供隔离的安全执行环境,保护敏感数据和操作。OpenHarmony的TEE模块基于OpenTrustee实现,采用微内核架构,为系统提供可信执行环境支持。OpenHarmony TEE模块是一个复杂的安全系统,通过提供隔离的执行环境保护敏感数据和操作。

m0_67505153的博客 558

4. SAP ABAP OData 服务 Data Provider Class 的 GET_ENTITYSET 方法实现指南

首先第19行CREATEDATA创建er_entityset实例,指定其类型为zcl_zbook_manage_mpc=>tt_book,接着把这个引用映射到刚刚第五行定义的FIELD-SYMBOLS变量上去,这样的话,接下来我们对FIELD-SYMBOLS进行的操作,就会自动反应回引用变量er_entityset.因为我们可能在这个方法里,返回多条图书信息,所以需要用内表类型,而非单条记录的ts_book.ts_book代表一本图书的数据结构。......

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 2968

多模态论文笔记——BLIP

本文详细介绍这几年AIGC火爆的隐藏功臣,多模态模型:BLIP。

haopinglianlian的博客 2455

多摄像头场景下 ISP 的同步与调度机制实战解析

在智能手机多摄系统中,主摄、广角、长焦、微距等摄像头的协同工作能力直接决定了影像系统的体验上限。而支撑这一能力的核心之一,正是 ISP 的同步与调度机制。ISP 需要处理多个 Sensor 的输入流、统一时序、资源仲裁、并发调度,并支持在不同模式间快速切换(如预览 → 拍照 → 视频)。本文将基于 Qualcomm、MTK、HiSilicon 平台的实际架构,系统性剖析 ISP 在多摄场景下的时序控制、Pipeline 配置、Buffer 管理与故障恢复机制,并分享实战中的典型问题与调试方案。

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 2360

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

上一篇: VC++ 中操作Excel文档的方法,读取,查询,写入,修改,删除
下一篇: VC++ API 如何获取文件夹路径
CreatedSign
博客等级 码龄14年 10粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址