gpt4 book ai didi

excel - 通过asp将excel内容保存到数据库

转载 作者:行者123 更新时间:2023-12-04 20:48:07 24 4
gpt4 key购买 nike

我使用下面的代码将 excel 文件上传到服务器。现在我需要将它保存到数据库中。谁能指导我如何做到这一点?

 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

上面的链接说您必须在服务器上安装 Excel,并且您必须在 Excel 文件上设置适当的权限才能从中读取。在这个过程之外,我不确定你会怎么做。

关于excel - 通过asp将excel内容保存到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2591371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com