saving excel content to a database through asp
i used the code below to upload an excel file to the server. now i need to save it to a database. can anyone guide mehow to do that?
开发者_JAVA百科 Dim SQLStr
SQLStr = "INSERT ALL INTO TABLENAME "
for each file in filCollection
file_name = file.name
path = folderObj & "\" & file_name
Set objExcel_chk = CreateObject("Excel.Application")
Set ws1 = objExcel_chk.Workbooks.Open(path).Sheets(1)
row_cnt = 1
'for row_cnt = 6 to 7
' if ws1.Cells(row_cnt,col_cnt).Value <> "" then
' col = col_cnt
' end if
'next
While (ws1.Cells(row_cnt, 1).Value <> "")
for col_cnt = 1 to 10
SQLStr = SQLStr & "VALUES('" & ws1.Cells(row_cnt, 1).Value & "')"
next
row_cnt = row_cnt + 1
WEnd
'objExcel_chk.Quit
objExcel_chk.Workbooks.Close()
set ws1 = nothing
objExcel_chk.Quit
Response.Write(SQLStr)
'set filobj = FSYSObj.GetFile (sub_fol_path & "\" & file_name)
'filobj.Delete
next
End if
End If
Read From Excel
The link above says you have to have Excel installed on the server and you must have the proper permissions set on the Excel file to read from it. Outside of this process, I'm not sure how you would do it.
精彩评论