当前位置:网站首页>怎样读取Excel表格到数据库
怎样读取Excel表格到数据库
2022-04-23 08:17:00 【lse2019】
方法一:使用SQL语句。
私_连接字符串 = “ODBC;DBQ=” + 我的excel文件 + “;Driver={Driver do Microsoft Excel(*.xls)};”
.子程序 读取外部数据到高级表格, , 公开.参数 参_连接字符串, 文本型, , connstr.参数 参_SQL查询语句, 文本型.参数 参_高级表格, 高级表格.局部变量 私_数据库连接1, 数据库连接对象.局部变量 私_记录集1, 记录集对象.局部变量 私_临时文本, 文本型.局部变量 i, 整数型.局部变量 j, 整数型参_高级表格.行数 = 1' 一、ADO连接私_数据库连接1.conn置连接字符串 (参_连接字符串) ' (1)置连接字符串.如果 (私_数据库连接1.conn打开 () = 真) ' (2)连接打开 ' 二、ADO记录集 私_记录集1.rs置活动连接 (私_数据库连接1.conn取连接对象本身 ()) ' (1)置记录集连接 私_记录集1.rs置数据源 (参_SQL查询语句) ' (2)置记录集数据源 .如果 (私_记录集1.rs打开 () = 真) ' (3)打开记录集 参_高级表格.列数 = 私_记录集1.rs字段数 () + 1 .计次循环首 (私_记录集1.rs字段数 () + 1, i) 参_高级表格.置数据 (0, 0, #表格常量.文本型, “序号”) 参_高级表格.置数据 (0, i, #表格常量.文本型, 私_记录集1.rs取字段名 (i - 1)) ' 调试输出 (私_记录集1.rs取得字段类型 (i - 1)) .计次循环尾 () i = 1 参_高级表格.可视 = 假 .判断循环首 (私_记录集1.rs尾记录后 () = 假) 参_高级表格.插入行 (, ) 参_高级表格.置数据 (i, 0, #表格常量.文本型, i) .计次循环首 (私_记录集1.rs字段数 (), j) 参_高级表格.置数据 (i, j, #表格常量.文本型, 私_记录集1.rs读文本 (私_记录集1.rs取字段名 (j - 1))) .' 如果真 (私_记录集1.rs取字段名 (j - 1) = “项目代码”) ' 调试输出 (私_记录集1.rs读文本 (私_记录集1.rs取字段名 (j - 1))) .如果真结束 .计次循环尾 () 私_记录集1.rs移动到下一条 () i = i + 1 .判断循环尾 () 参_高级表格.可视 = 真 私_记录集1.rs关闭 () ' 关闭当前记录集 .否则 信息框 (“打开记录集失败。” + 到文本 (私_记录集1.rs取状态 ()), 16 + 0, “提示”) .如果结束 私_数据库连接1.conn关闭 () ' 断开连接 高级表格_交替色显示 (参_高级表格).否则 信息框 (“连接到数据源失败。”, 16 + 0, “提示”).如果结束
版权声明
本文为[lse2019]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4196005/blog/5516928
边栏推荐
- QFileDialog select multiple files or folders
- How to encrypt devices under the interconnection of all things
- pdf加水印
- Description of the abnormity that the key frame is getting closer and closer in the operation of orb slam
- 数论求a^b(a,b为1e12级别)的因子之和
- ajax防止缓存方法
- jsp页面编码
- K210学习笔记(二) K210与STM32进行串口通信
- Introduction to protobuf
- Idea: export Yapi interface using easyyapi plug-in
猜你喜欢

Asan minimalism
![[learning] audio and video development from scratch (9) -- nuplayer](/img/62/20b0d80088181fb6ff1fe842500c0a.png)
[learning] audio and video development from scratch (9) -- nuplayer

Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code

Community group purchase applet source code + interface DIY + nearby leader + supplier + group collage + recipe + second kill + pre-sale + distribution + live broadcast

CGM optimizes blood glucose monitoring and management -- Yiyu technology appears in Sichuan International Medical Exchange Promotion Association

虚拟线上展会-线上vr展馆实现24h沉浸式看展

HAL库的RCC简介

根据字节码获取类的绝对路径

作文以记之 ~ 二叉树的前序遍历

excle加水印
随机推荐
Copy array in JS
Comparison of indoor positioning technology
Queue (C language / linked list)
QT compilation qtxlsx Library
耳穴诊疗随笔0421
okcc呼叫中心外呼系统智能系统需要用多大的盘存录音?
什么是RPC
Use of applicationreadyevent
分布式消息中间件框架选型-数字化架构设计(7)
Navicat远程连接mysql
RPC过程
关于数组复制问题
input元素添加监听事件
ATSS(CVPR2020)
QFileDialog select multiple files or folders
Multi vision slam
Protobuf简介
form表单 post提交 数据量大的问题
5.6 comprehensive case - RTU-
My heart's broken! A woman's circle of friends envied others for paying wages on time and was fired. Even her colleagues who liked her were fired together