//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop #include "ProcessBar.h"
#include <stdio.h> // For FILE, fopen, fstat, fileno, fread and fclose
#include <sys\stat.h> // For fstat and the stat struct
#include <Math.hpp> // For Min
#include <memory> //For STL auto_ptr class //---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm4 *Form4;
//---------------------------------------------------------------------------
__fastcall TForm4::TForm4(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm4::btn1Click(TObject *Sender)
{
FILE *F;
char MyData[];
long BytesRead; F = fopen("../oui.txt", "r"); // Path relative to Debug
// Use a file larger than 2048 bytes to make it interesting.
if (F)
{
struct stat statbuf;
fstat(fileno(F), &statbuf);
pb1->Max = statbuf.st_size;
if (pb1->Max > )
{
pb1->Step = (pb1->Max)/;
pb1->Step = Min(pb1->Step, );
}
else
pb1->Step = pb1->Max;
std::auto_ptr<char> DataBuffer(new char[pb1->Step]);
for (pb1->Position = ;
pb1->Position < pb1->Max;
pb1->StepIt()) // Move the ProgressBar Position using StepIt.
{
fread(DataBuffer.get(), pb1->Step, , F);
// Do this or else the read wraps and starts over.
pb1->Step =
Min(pb1->Step, pb1->Max - pb1->Position);
} mmo1->Lines->Add(DataBuffer.get()); fclose(F);
DataBuffer.release();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm4::btn2Click(TObject *Sender)
{ Variant vExcelApp, vWorkbook, vRange, Sheet1;
vExcelApp = Variant::CreateObject("Excel.Application");
vExcelApp.OlePropertySet("Visible", false);
vExcelApp.OlePropertyGet("WorkBooks").OleProcedure("Open",
dlgOpen1->FileName.c_str());
vWorkbook = vExcelApp.OlePropertyGet("ActiveWorkbook"); int BookCount = vWorkbook.OlePropertyGet("Sheets").OlePropertyGet
("Count");
for (int i = ; i < BookCount; i++)
{
AnsiString SheetName = vWorkbook.OlePropertyGet("Sheets", i + )
.OlePropertyGet("Name");
// ShowMessage(SheetName); } // Sheet1 = vWorkbook.OlePropertyGet( "ActiveSheet ");
// vExcelApp.Exec(PropertyGet( "Cells ") < <1 < <3).Exec(PropertySet( "Value ") < <15); //赋值
// Sheet1.OlePropertyGet( "Rows ", 1).OlePropertyGet( "Insert "); //插入
String kkl, hgf;
int it = , st = ; while (it > && BookCount >= st)
{
vWorkbook.OlePropertyGet("Sheets", st).OleProcedure("Select");
// 选择sheet
for (it = ; it <= ; it++)
{
kkl = vExcelApp.Exec(PropertyGet("Cells") << << it);
//if (kkl.Pos(qz1) > 0 || kkl.Pos(qz2) > 0) // 读取
break;
}
st++;
} int kk = ;
for (kk = ; kk <= ; kk++)
{
kkl = vExcelApp.Exec(PropertyGet("Cells") << kk << it);
//if (kkl.Pos(qz1) > 0 || kkl.Pos(qz2) > 0) // 读取
break;
} hgf = vExcelApp.Exec(PropertyGet("Cells") << kk << it + );
int ki = ;
while (hgf.Trim() != "")
{
if (ki == StringGrid2->RowCount - )
//StringGrid1->RowCount++;
// kkl==vExcelApp.Exec(PropertyGet( "Cells ") < <kk < <it); StringGrid2->Cells[][ki] = vExcelApp.Exec
(PropertyGet("Cells") << kk << it); // 2-4列的数据
StringGrid2->Cells[][ki] = vExcelApp.Exec
(PropertyGet("Cells") << kk << it + );
StringGrid2->Cells[][ki] = vExcelApp.Exec
(PropertyGet("Cells") << kk << it + );
kk++;
ki++;
hgf = vExcelApp.Exec(PropertyGet("Cells") << kk << it + );
} vExcelApp.OlePropertyGet("ActiveSheet").OlePropertyGet("Cells ", , )
.OleProcedure("Select");
vRange = vExcelApp.OlePropertyGet("Selection");
vRange.Exec(Function("Sort") << vExcelApp.OlePropertyGet("Selection")
<< ); // vWorkbook.OleProcedure( "Save");
vWorkbook.OleProcedure("Close");
vExcelApp.OleFunction("Quit");
vWorkbook = Unassigned;
vExcelApp = Unassigned;
}
// ---------------------------------------------------------------------------

C++ builder 2010 操作Excel表格的编程实现的更多相关文章

  1. VS2010 C++ 操作Excel表格的编程实现

    转载请注明原文网址: http://www.cnblogs.com/xianyunhe/archive/2011/09/25/2190485.html 通过VC实现对Excel表格的操作的方法有多种, ...

  2. qt 操作excel表格

     自己编写的一个Qt C++类,用于操作excel表格,在Qt中操作excel需在.pro中增加CONFIG+=qaxcontainer配置. 1.打开Excel:objExcel = new QAx ...

  3. Python 利用Python操作excel表格之openyxl介绍Part2

    利用Python操作excel表格之openyxl介绍 by:授客 QQ:1033553122 欢迎加入全国软件测试交流qq群(群号:7156436) ## 绘图 c = LineChart()    ...

  4. Python 利用Python操作excel表格之openyxl介绍Part1

    利用Python操作excel表格之openyxl介绍 by:授客 QQ:1033553122 欢迎加入全国软件测试交流qq群(群号:7156436),免费获取以下性能监控工具(类似Nmon精简版) ...

  5. 【转】python操作excel表格(xlrd/xlwt)

    [转]python操作excel表格(xlrd/xlwt) 最近遇到一个情景,就是定期生成并发送服务器使用情况报表,按照不同维度统计,涉及python对excel的操作,上网搜罗了一番,大多大同小异, ...

  6. Python 利用Python操作excel表格之xlwt介绍

    利用Python操作excel表格之xlwt介绍   by:授客 QQ:1033553122 直接上代码   案例1 #!/usr/bin/env python # -*- coding:utf-8 ...

  7. 用NPOI、C#操作Excel表格生成班级成绩单

    在C#中利用NPOI操作Excel表格非常方便,几乎上支持所有的Excel表格本身所有的功能,如字体设置.颜色设置.单元格合并.数值计算.页眉页脚等等. 这里准备使用NPOI生成一个班级成绩单Exce ...

  8. python - 操作excel表格

    说明:由于公司oa暂缺,人事妹子在做考勤的时候,需要通过几个excel表格去交叉比对员工是否有旷工或迟到,工作量大而且容易出错. 这时候it屌丝的机会来啦,花了一天时间给妹子撸了一个自动化脚本. 1. ...

  9. 转载:python操作excel表格(xlrd/xlwt)

    python操作excel表格(xlrd/xlwt)   最近遇到一个情景,就是定期生成并发送服务器使用情况报表,按照不同维度统计,涉及python对excel的操作,上网搜罗了一番,大多大同小异,而 ...

随机推荐

  1. [Tex学习]给汉字注音

    \documentclass{article} \usepackage[CJK]{ruby} \usepackage{pinyin} \begin{document} \begin{CJK*}{GBK ...

  2. JavaScript: bind apply call

    var foo = function(age,sex){ console.log(this.name,age,sex); }; //call将改变函数运行的context foo.call({name ...

  3. MongoDB基本命令的使用

    成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操作. 输入help可以看到基本操作命令: show dbs:显示数据库列表 show collections:显示 ...

  4. java多线程之AtomicInteger

    AtomicInteger原子操作实现同步 package Thread.Common; import java.util.Timer; import java.util.TimerTask; imp ...

  5. java io操作常规

    1.四种类型: 字节流: InputStream OutputStream 字符流: Reader Writer 2.转换流 InputStreamReader, OutPutStreamWriter ...

  6. ubuntu14.04配置Hive1.2.1

    1.添加环境变量:vi ~/.bashrc #HIVE VARIABLES START export HIVE_HOME=/usr/local/hive-1.2.1 export PATH=$PATH ...

  7. GroupId和ArtifactId

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --><dependency> ...

  8. MPlayer在ARM上的移植(S5PV210开发板)

    MPlayer 1.0已经把大部分解码库都自带了,如ffmpeg,但是自带的音频库在S5PV210下效果非常不好.换成使用libmad效果不错.因此MPlayer 在ARM-Linux的最简单的移植只 ...

  9. 11-UIView与核心动画对比

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  10. Android Studio 修改 包名 package name

    我们的包名中含有Nav,造成声音不能正常出来:需要改包名,但 android studio 改包名原来还是比较麻烦的,不过现在简单多了: 第一步,直接打开 AndroidManifast.xml 文件 ...