有没有人可以通过自动启动会话来分享有关如何在 Ms.Excel 2007 中自动执行 Web 查询的知识?
我的问题是我每次都需要通过网络查询手动登录......
有没有人可以通过自动启动会话来分享有关如何在 Ms.Excel 2007 中自动执行 Web 查询的知识?
我的问题是我每次都需要通过网络查询手动登录......
使用 C# COM INTERFACE FOR EXCEL,通过它你可以将任何数据注入 EXCEL……用以下搜索关键字点击谷歌,你会得到 100 条结果
使用 Excel = Microsoft.Office.Interop.Excel;
现在以上基本上只在 ASP.NET 中是可能的。否则,您可以使用相应的编程语言获得 excel 界面。
看到这个你会有所了解的..
以我的经验,这是不可能的。Excel 的 Web 查询界面不具备执行此操作的功能。我求助于通过 VBA 获取 Web 数据并将其粘贴到工作表中以自动化登录部分。请参阅http://www.dailydoseofexcel.com/archives/2011/03/08/get-data-from-website-that-requires-a-login/并务必阅读评论。
我有确切的问题..
使用一点 Vba 宏,我可以自动执行数据传输.. 但我仍然必须手动启动会话..
只需一点代码,您就可以自动将数据传输到 excel 中,您可以使用一些 do - 循环自动逐行记录每个数据。例如;
Do
If getVars = "" or getVars = Null Then
Exit Do
End If
Set RangeOfStyles = Range("A1:Z400")
'Clear the xlSheet
For Each Cell In RangeOfStyles
On Error Resume Next
ActiveWorkbook.Styles(Cell.Text).Delete
ActiveWorkbook.Styles(Cell.NumberFormat).Delete
Next Cell
DoEvents
'Use a counter for detecting the range of recieved data in table
'This only works if there is nospace inside the recieved data
'Create a start point
i = 2
'Find the start point
'Will be used if there are some data already found..
'If the starting cell is not empty than start counting
If Cells(i, 2) <> "" Then
Do
Do
i = i + 1 '2 cause my data starts at column "B2" and row 2
Loop Until Cells(i + 1, 2) = "" 'if next cell is empty than it ends here
'im leaving an empty row to seperate each data
'i must check the row after the empty row to find out if there are more data
'+1 for empty cell and +1 for starting cell
i = i + 2
Loop Until Cells(i, 2) = ""
End If
'Now that we are ready we can paste our next data to the next rows of our worksheet
'Get ur url pasted to the excel
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://127.0.0.1" + getVars, _ 'I used your url here to make it more simpler
Destination:=Range("B" & i, "I" & i))
'Use this ability only if you need to gather a specific table in that page
.WebSelectionType = "xlSpecifiedTables"
'Webtables = "ChosenTable"
.WebTables = "10"
'The other attributes! Nothing fancy here..
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
Loop