和之前讲的一样,我们讲过代码就知道了是怎么生成的,所以这个导入功能也是一样的。
第一步:
我们从vbscript 开始调用
‘说明:导出模板
Private Sub ExportTemp()
Call ExportExcelTemplate("IG0050", "防腐管检查信息表", frmHtmlData.UID.value)
End Sub
‘说明:导入数据
Private Sub ImportData3()
dim ls_para
ls_para= document.all.FormPara_ParentID.value
Call ImportExcelDataToDb("IG0050", "钢板信息导入模板",frmHtmlData.UID.value,3,4,"<Handle Type=‘0‘ Code=‘ParentID‘ Value=‘" & ls_para &"‘ />")
End Sub
‘校验
Private Sub CheckValidExcelData(ByVal as_File,ByVal al_StartRow,ByVal al_EndRow)
dim ls_xml,ls_sql
ls_xml = "<Root Handle=‘CheckExcel‘ Code=‘IG0050‘ CodeIndex=‘B‘ ExcelFile=‘" & as_File &"‘ StartRow=‘" & al_StartRow &"‘ EndRow=‘" & al_EndRow &"‘></Root>"
ls_sql = "select PipeNo from CJ103"
Call ExcelDataCheck(frmHtmlData.UID.value,ls_xml,ls_sql,"G0050","PipeNo","管道编号","CJ001","PipeNo","钢管信息表")
End Sub
注意看这个ImportExcelDataToDb文件,他放在服务器
这个位置: \Include\ImportExportData.vbs; 要在界面里引用这个路径。
然后就是找到这个文件我们可以看一下,主要的片段代码
Private Sub ImportExcelDataToDbAll(ByVal as_ModelCode, ByVal as_Name, ByVal as_Guid, ByVal al_StartRow, ByVal al_EndRow, ByVal as_Xml, ByVal ab_Select)
Dim ls_File : ls_File = mo_PublicProc.FileUpload2(1, "xls|xlsx", 10, False)
If ls_File = "" Then Exit Sub
ls_File = Left(ls_File, InStr(1, ls_File, "[") - 1)
Dim ls_Text : ls_Text = ""
If al_StartRow = -1 And al_EndRow = -1 Then
ls_Text = mo_PublicProc.ShowWindow("SelectImportExcelRow.aspx?UID=" & as_Guid, "", "300px", "180px")
If ls_Text = "" Then Exit Sub
Else
If al_StartRow > 0 And al_EndRow > 0 Then
If ab_Select Then
ls_Text = mo_PublicProc.ShowWindow("SelectImportExcelRow.aspx?StartRow=" & CStr(al_StartRow) & "&EndRow="& CStr(al_EndRow) & "&UID=" & as_Guid, "", "300px", "180px")
If ls_Text = "" Then Exit Sub
Else
ls_Text = CStr(al_StartRow) & "," & CStr(al_EndRow)
End If
End If
End If
Call IsValidExcelData(ls_File)
If mb_RunScript = False Then Exit Sub
Dim ls_Url : ls_Url = "ImportExportHandle.aspx?UID=" & as_Guid
Dim ls_Xml : ls_Xml = "<Root Handle=""ImportData"" DeleteExcelProcess=""" & CStr(mi_DeleteExcelProcess) & """ Code=""" & as_ModelCode & """ ExcelFile=""" & ls_File & """ Row=""" & ls_Text & """>" & as_Xml & "</Root>"
ls_Xml = mo_PublicProc.Handle(ls_Url, ls_Xml, "导入Excel数据文件", "导入", True)
If ls_Xml = "" Then Exit Sub
Call RefreshWindow
End Sub
注意看到这个url的路径 :Dim ls_Url : ls_Url = "ImportExportHandle.aspx?UID=" & as_Guid
用的是i界面对吧
然后i界面发布在哪里呢?
就是ImportExportHandle.aspx 文件里,就是发步在Application 里,内容如下:
<%@ Page Language="vb" AutoEventWireup="false"
Inherits="CMFly.Web.Base.TApp_ImportExportHandleServer" %>
意思就是所要用dll文件还是在bin里面运行,由CMFly.Web.Base.TApp_ImportExportHandleServer
由这个解决方案来写的
问题大致就是只有一个过程了