当前位置:网站首页>Vfpbs uploads excel and saves MSSQL to the database
Vfpbs uploads excel and saves MSSQL to the database
2022-06-30 05:20:00 【VFP of Garfield】
development environment
Back end :VFP SP2 7423 + Qiyou three-tier development framework ( Cat frame )
front end :VUE2.0+Element
Ideas
- Realization BS Upload
- Is to use the cat frame importexcel Class will EXCEL Convert file to temporary table ,
- Insert a temporary table into DAL_CA One click save in .
1. So let's look at this first MSSQL data structure

2. The code generator generates DAL_CA class

3. The generated DAL_CA Class saved to the development framework DAL Directory
Class name is the same as file name 
4. Write business logic controller class
Define Class ctl_skin_ht as session
*-- Upload import file
Procedure upfile
oResult=GetUpFile() && Returns as a collection object
*-- original file name
cOldFilename=oResult.ofieldcoll.Item("file").filename && file name Follow upload name( WeChat ) Corresponding key (mui) Corresponding
cExtName=Justext(cOldFilename) && Extension
IF !INLIST(UPPER(cExtName),"XLS","XLSX")
ERROR " Must upload EXCEL file "
ENDIF
cFilename=Ttoc(Datetime(),1)+Right(Transform(Second()*1000),6)
cFilename=cFilename+"."+cExtname
cMydata=oResult.ofieldcoll.Item("file").fielddata && The contents of the document
cFilePath=getwwwrootpath("upfile")
If !Directory(cFilePath)
Md &cFilePath && At present, it is only successfully executed under the debugging server , Pre create when publishing
Endif
If Strtofile(cMydata,cFilePath+cFilename)<=0
Error " Failed to write file , Whether the directory exists and is readable and writable "
Endif
*-- Import EXCEL Generate temporary tables
xx=Newobject("importexcel","importexcel.prg")
xx.cursorstruc=" Mobile phone model c(240), Number c(50)"
xx.Alias="tmpxxx"
If !xx.Import(Sys(5)+Sys(2003)+"\"+cFilePath+cFilename)
Error xx.msg
Endif
*-- Temporary table write DAL class , Realize one click save
oDAL=Newobject("Dal_skin","Dal_skin.prg")
oDAL.Nodata=.T.
If !oDAL.CursorFill(.T.)
Aerror(laerror)
Error laerror(2)
Endif
cTmpAlias=oDAL.Alias
Insert Into &cTmpAlias(model,skincode,mainmodel,types,Type,Memo,price) Select * From tmpxxx
If !oDAL.Save()
Error oDal.msg
Endif
Return cursortojson(oDAL.alias)
Endproc
ENDDEFINE
5. Front page , You can also write your own upload page
Put down an upload component
<el-upload
:on-success="handle_success"
class="upload-demo"
:action="upurl"
multiple
:limit="1"
>
<el-button size="small" type="primary"> Click upload </el-button>
<div slot="tip" class="el-upload__tip"> Can only upload excel file </div>
</el-upload>
JS Code
export default {
components: {},
data() {
return {
upurl:"ctl_skin_ht.fsp?proc=upfile"
},
methods: {
handle_success(res){
console.log(res);
if(res.errno!=0){
this.$message.warning(res.errmsg);
return;
}
this.$message.warning(" Upload successful ");
},
}
}
Run the debug server , Test upload , Perfect success . But publish to IIS an :

The next chapter continues to fill the pit
边栏推荐
猜你喜欢

Assembly learning tutorial: accessing memory (3)

网络变压器怎么判断好坏?网络滤波变压器坏了一般是什么症状?

mmcv常用API介绍

Unity publishing /build settings

【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)

Pit of smoothstep node in shadergraph

Responding with flow layout
![[vcs+verdi joint simulation] ~ take the counter as an example](/img/fb/214a4e65c53503ecbc38a5e43523cf.png)
[vcs+verdi joint simulation] ~ take the counter as an example

Force buckle 704 Binary search

Bev instance prediction based on monocular camera (iccv 2021)
随机推荐
Unity2019.3.8f1 development environment configuration of hololens2
Virtual and pure virtual destructions
Unity + hololens2 performance test
How to use js to control the scroll bar of moving div
Unity project hosting platform plasticscm (learn to use 2)
Summary of common loss functions in pytorch
Database base (Study & review for self use)
Introduction to Redux: initial experience of Redux
产生 BUG 测试人员需要自己去分析原因吗?
2021-06-17 solve the problem of QML borderless window stretching, window jitter and flicker when stretching and shrinking
炒美原油的国际交易平台如何能保障资金安全呢?
Unity project hosting platform plasticscm (learn to use 1)
GoLand No Tests Were Run : 不能使用 fmt.Printf() &lt;BUG&gt;
[typescript] experimentaldecorators of vscode stepping pit
Operation file file class method
Gradient clip in dqn
Super comprehensive summary | related improvement codes of orb-slam2 / orb-slam3!
Operation of JSON file
Detailed explanation of the loss module of mmdet
Win10 vs2015 compiling curaengine