excel|web|数据|数据库|页面
笔者由于工作需要,在OA系统中,需要将EXCEL文件的内容导入到数据库中,同时还需要将数据库中的内容导出到EXCEL文件中。笔者的OA是用PHP开发的,并且应用在WEB页面上,所以直接用PHP处理难度比较大。经过研究,笔者用DELPHI开发了一个ACTIVEX控件,来处理EXCEL文件的数据,然后将数据提交到服务器上,再保存到数据库中,轻松的实现了EXCEL文件数据的导入。导出没有用ACTIVEX控件,直接用PHP处理。方法是将数据直接生成CSV文件,因为CSV是逗号分隔的文本文件,并且可以直接用EXCEL打开处理,所以可以满足要求。 下面将实现的方法介绍一下。导入的页面代码: "人员编号", "FIELDNAME"=>"STUFFID", "FIELDTYPE"=>"A"), array ("CAPTION"=>"开始日期", "FIELDNAME"=>"BEGINDATE", "FIELDTYPE"=>"A"), array ("CAPTION"=>"结束日期", "FIELDNAME"=>"ENDDATE", "FIELDTYPE"=>"A"), array ("CAPTION"=>"合同内容", "FIELDNAME"=>"CONTRACTTEXT", "FIELDTYPE"=>"A"), array ("CAPTION"=>"备注", "FIELDNAME"=>"THISMEMO", "FIELDTYPE"=>"A"), array ("CAPTION"=>"服务器文件名", "FIELDNAME"=>"DOCFILE", "FIELDTYPE"=>"A"), array ("CAPTION"=>"文件类型", "FIELDNAME"=>"FILETYPE", "FIELDTYPE"=>"A"), array ("CAPTION"=>"本地文件名", "FIELDNAME"=>"FILENAME", "FIELDTYPE"=>"A"), array ("CAPTION"=>"文件扩展名", "FIELDNAME"=>"EXTNAME", "FIELDTYPE"=>"A")); //构造SQL语句,字段名部分 $strSQL = "INSERT INTO HR_WORKCONTRACT ("; $strTemp = ""; for ($i = 0; $i ExecSQL ($strSQL.$strTmp)) $do->SetObject ("ERR", "数据导入失败!"); else $do->SetObject ("ERR", "数据导入成功!"); //echo $strSQL.$strTmp; $strTmp = ""; } } } if (trim ($strTmp) != "") { $strTmp = substr ($strTmp, 0, strlen ($strTmp) - 2).";"; if (!$do->ExecSQL ($strSQL.$strTmp)) $do->SetObject ("ERR", "数据导入失败!"); else $do->SetObject ("ERR", "数据导入成功!");//echo $strSQL.$strTmp; } }?>劳动合同信息导入 导入数据的页面如下: 可以显示导入EXCEL文件的所有内容,并且可以手工选择要导入的数据,可以对数据进行临时的修改处理(修改过后数据以红颜色显示,以示区别)。 选择文件界面。可以选择本地硬盘上的EXCEL文件,包括XLS文件和CSV两种格式。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!
