我正在google网站上构建一些“列表”(基于页面模板)页面。这一切都很棒。但问题是我希望将本地副本(电子表格)作为备份或离线使用。
我的第一个问题是:我可以以某种方式将列表下载为电子表格吗?
此外,如果我可以使用列表模板的漂亮功能(例如,一个简单的表单输入条目的所有数据)会更好;我已经在列表模板中使用它,包括下拉列表,如以及按列排序的能力!)同时能够下载列表的应对或将其存储在我的云端硬盘中。
这可能吗?怎么样?
感谢
答案 0 :(得分:0)
是的,您可以...分类。可以使用以下功能在Google表格中进行一些基本的Web抓取:
在IMPORTXML
和IMPORTHTML
之间非常适合获取特定数据,而 Sub OverallProcess()
Dim sheet1 As Worksheet, Sheet2 As Worksheet, wbkA As Workbook, wbkB As Workbook, wbkAColB As
Variant, wbkBColB As Variant
Dim i As Long, j As Long, k As Long: k = 2
Dim isFound As Boolean: isFound = False
Application.ScreenUpdating = False
'read column in master document
Set sheet1 = Sheets(1)
Set Sheet2 = Sheets(2)
Sheet1ColB = sheet1.Range("B2:D" & sheet1.Cells(sheet1.Rows.Count, 2).End(xlUp).Row).Value2
'Open up next linked workbook from list and read column
Dim sFullName As String
Dim t As Integer
Dim wsh As Worksheet
'On Error GoTo Err_openFiles
Set wsh = ThisWorkbook.Worksheets("Sheet2")
t = 1
Do While wsh.Range("A" & t) <> ""
sFullName = wsh.Range("A" & t)
Application.Workbooks.Open sFullName, UpdateLinks:=False
't = t + 1
'Loop
'Exit_openFiles:
'On Error Resume Next
'Set wsh = Nothing
'Exit Sub
'Err_openFiles:
'MsgBox Err.Description, vbExclamation, Err.Number
'Resume Exit_openFiles
'Read column in open linked document
Set varsheet2 = ActiveWorkbook.Worksheets("Sheet1")
wbkBColB = varsheet2.Range("B2:B" & varsheet2.Cells(varsheet2.Rows.Count, 2).End(xlUp).Row).Value2
'Loop through part numbers to find matches and non-matches
For i = LBound(wbkBColB) To UBound(wbkBColB)
isFound = False
For j = LBound(Sheet1ColB) To UBound(Sheet1ColB)
'perform case insensitive (partial) comparison
If InStr(1, LCase(wbkBColB(i, 1)), LCase(Sheet1ColB(j, 1))) > 0 Then
'If it finds a match, it highlights cell green
Cells(k, 2).Interior.ColorIndex = 4
'Numbers below in brackets are the columns Note: The 'j' numbers are 1 below the k numbers
'k numbers ColA =1, ColB =2, ColC=3 etc
'j numbers, ColB = 1, ColC =2, ColD=3 etc
varsheet2.Cells(k, 3) = Sheet1ColB(j, 2)
varsheet2.Cells(k, 4) = Sheet1ColB(j, 3)
k = k + 1
isFound = True
End If
Next
If Not isFound Then
'If it doesn't find a match, it highlights the cell yellow
Cells(k, 2).Interior.ColorIndex = 6
k = k + 1
End If
Next
'Saving the files into a new folder with an uprevved name
Dim filepath As String
Dim filename As String
Dim filepatharch As String
Dim filelist As String
Dim filedate As String
Dim filecount As Integer
'Set where to save and the file naming convention
filepath = "H:\BoM Drafts Macro\"
filename = ActiveWorkbook.Name
Str1 = Left(filename, InStr(filename, ".") - 1)
Title = Right(Str1, Len(Str1) - InStr(Str1, " "))
LastNum = Right(Left(Str1, Len(Str1) - Len(Title) - 1), Len(Str1) - Len(Title) - 14)
ShortName = Left(Str1, 13)
If InStr(filename, ".") > 0 Then
Str1 = Left(filename, InStr(filename, ".") - 1)
Title = Right(Str1, Len(Str1) - InStr(Str1, " "))
LastNum = Right(Left(Str1, Len(Str1) - Len(Title) - 1), Len(Str1) - Len(Title) - 14)
ShortName = Left(Str1, 13)
End If
LastNum = CStr(CInt(LastNum) + 1)
Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs filename:= _
filepath & ShortName & LastNum & " " & Title & ".xlsx"
ActiveWindow.Close
t = t + 1
Loop
MsgBox t & "files opened", vbInformation
End Sub
非常适合获取表Using Google Sheets as a basic web scraper。
您可以从那里下载带有列表的Google表格,并将副本通常保存在Google云端硬盘中,甚至可以将其导出为PDF或excel文件。