免费教程_免费网赚教程_破解版软件-寂涯网络学习基地

当前位置: 主页 > 系统综合 > 各类编程 > c++Builder由Excel数据导入Paradox表的实现(2)

c++Builder由Excel数据导入Paradox表的实现(2)

时间:2012-05-10 22:27来源:未知 整理:寂涯网络 点击:


Buttons()<<mbOK.O): if(Str【il==T.t|eStr【il)
l i++:
//启动Excel应用程序f臣不显示 else
Ex.OlePropertySet(。Visible',false); {
册丁开指定的文件 if(i==1)
Ex.OlePropertyGet('WorkBooks。).OleFunction(。Open。, i++:
0penDialogl—->FileName.c_strO); else
Wb=Ex.OlePropertyGet(。ActiveWorkBook。): {
Sh=Wb.OlePropertyGet(。ActiveSheet。): IsMatch=false;
//读取表格第一行前7个单元格内容,用于判断表格文 MessageDlg I。文件格式不匹配!。,mtError,
//件格式是否正确TMsgDIgButtonsO<<mbOK.O):
AnsiString Str[7]; break;
Str[O]=Sh.OlePropertyGet(。Cells。。1,1).OlePropertyGet(。 l
Value。): l
Str[1】=Sh.OlePropertyGet(。Cells',1.2).OlePropertyGet(。 l
Value。): if(IsMatch)//如果文件格式匹配,则导入数据
Str[2]=Sh.OlePropertyGet(‘Cells',1,3).OlePropertyGet(。 {
Value‘):TOuery+Queryl=newTQuery(this);
Str[3]=Sh.OlePropertyGet(。Cells',1.4).OlePropertyGet(。 //RequestLive属性用于确定是否希望从查询指令中
Value。):
Value。):
Value。):
Str[4]=Sh.OlePropertyGet(。Cells',1.5).OlePropertyGet(。
Str[5]=Sh.OlePropertyGet(。Cells',1.6).OlePropertyGet(。
Str[6]=Sh.OlePropertyGet(。Cells",1.7).OlePropertyGet(‘
,/获取可读可写的查询结果,
,/缺省设置为假,表示查询结果只读。如果要使记录
,,能够编辑,需要设置该属性为真。
,,这里,要写入数据,故设罱为真。
Queryl一>RequestLive=true:
Queryl一>DatabaseName=。D:W:
Ouewl..>Close();
Queryl一>SQL一>Clear();
Quell一>SQL一>Add(。select’from studentinfo.db。):
Queryl一>Open():
int RowCount;
/,返同ExceI工作表的行数
RowCount=Sh.OlePropertyGet(。UsedRange。)
OlePropenyGet(。Rows。).
OlePropertyGet(。Count。):
AnsiString InputStr[7];//当前导入信息
AnsiString FilterString;//筛选条件
int RecCount;
int AddCount=0;,/添加记录数量
for(int j=O;j<RowCount一1:j++)
{
,/读取学号
InputStr【0】=Sh.OlePropertyGet(‘Cells。,j+2,1)
OlePropertyGet(“Value。):
删且织筛选条件字符串
FilterString=Queryl->Fields->Fields 10】一>
FieldName+。=。+StrToInt(InputStr[0]);
Queryl->Filtered=false;
Quell->Filter=FilterString;
Quell一>Filtered=true:
II半JJ断记录是否存在
RecCount=Queryl..>RecordCount;
ifIRecCount==0)//不存在
{
Queryl—->Close();
Queryl一>SQL一>Clear();
Queryl一>SQL一>Add (。select
+
from
studentinfo.db。):
Queryl一>OpenI):
/厂读取姓名
lnputStr 11 1=Sh.OleProperb/rGet
OlePropertyGet('Value。):
,/读取性别
InputStr【2】=Sh.OlePropertyGet
OlePropertyGet(。Value。):
//读取性别
InputStr 13】=Sh.OlePropertyGet
OlePropertyGet(。Value。):
,/i卖取性别
InputStr【4l=Sh.OlePropertyGet
OlePropertyGet(。Value。):
∥读取性别
InputStr f5J5=Sh.OlePropertyrGet
i曼/盎嚣与簟耥
《。Cells‘,j+2,2).
(。Cells。,j+2,3)
(。Cells。,j+2.4)
(。Cells。,j+2,5)
(。Cells。.j+2,6)
密集
OlePropertyGet(。Value。J:
//i卖取性别
InputStr 16】=Sh.OlePropertyGet(。Cells。,j+2,7)
OlePropertyGet(。Value。):
,,在数据表最后添加一个空记录
Quell->Append();
∥将数据赋给数据记录各字段
Queryl一>Fields一>Fields[0]一>V8Iue=InputStr【O】:
Quell一>Fields一>Fields[1】一>VaIue=InputStr【1 l:
Quell一>Fields一>Fields[2]一>VaIue=InputStr【2l:
Queryl一>FieIds一>FieIds【3卜.>Value=lnputStr[3];
Queryl一>FieIds一>FieIdsf4】一>VaIue=InputStr【4J:
Queryl->Fields一>Fields[5]一>VaIue=InputStr【5】:
Queryl一>FieIds一>FieIdsf6】一>Value=InputStr【6】:
//提交修改
Queryl一>Postl):
IlgWu的记录数加1
AddCount++;
l
Queryl->Filtered=faIse;
}
delete OpenDialogl:
delete Queryl:
AnsiString Msg=。共添加。+IntToStr(AddCount)+。条记录!‘:

本页地址 http://www.jybase.net/biancheng/20120510916.html

百度搜索更多

谷歌搜索更多

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------

评价:
昵称: 验证码:点击我更换图片
推荐内容
赞助商
赞助商


关于本站免责声明视频更新google百度地图视频地图RRS订阅

如有什么问题请在本站留言,或发邮件到 hxt167#foxmail.com