我正在基于python-flask的API上尝试XHR GET请求,并收到此错误:
Sub copyNonBlankData()
Dim erow As Long, lastrow As Long, i As Long
Dim ws As Worksheet
Set ws = ActiveWorkbook.Worksheets("Sheet1") 'Sheet name
Dim ws2 As Worksheet
Set ws2 = ActiveWorkbook.Worksheets("Sheet2") 'Sheet name
lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
erow = ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
For i = 4 To lastrow
If ws.Cells(i, 1) <> "" Then
ws.Range(ws.Cells(i, 1), ws.Cells(i, 1)).Copy 'Copy Serial number
ws2.Range(ws2.Cells(erow, 1), ws2.Cells(erow, 1)).PasteSpecial xlPasteAll 'Paste serial
ws.Range(ws.Cells(i, 2), ws.Cells(i, 2)).Copy 'Copy date
ws2.Range(ws2.Cells(erow, 3), ws2.Cells(erow, 3)).PasteSpecial xlPasteAll 'Paste serial
ws.Range(ws.Cells(i, 3), ws.Cells(i, 4)).Copy 'Copy values
ws2.Range(ws2.Cells(erow, 5), ws2.Cells(erow, 6)).PasteSpecial xlPasteAll 'Paste values
ws2.Range(ws2.Cells(erow, 4), ws2.Cells(erow, 4)).Interior.Color = RGB(255, 242, 204) 'Fill Colour in 3rd column
ws2.Range(ws2.Cells(erow, 2), ws2.Cells(erow, 2)).Borders(xlEdgeBottom).LineStyle = xlContinuous 'Add borders to 2nd column
ws2.Range(ws2.Cells(erow, 4), ws2.Cells(erow, 4)).Borders(xlEdgeBottom).LineStyle = xlContinuous 'Add borders to 4th column
erow = erow + 1
End If
Next i
Application.CutCopyMode = False
End Sub
服务器代码:
Sub copyNonBlankData()
Dim erow As Long, lastrow As Long, i As Long
Dim ws As Worksheet
Set ws = ActiveWorkbook.Worksheets("Sheet1") 'Sheet name
Dim ws2 As Worksheet
Set ws2 = ActiveWorkbook.Worksheets("Sheet2") 'Sheet name
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False
lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
erow = ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
For i = 4 To lastrow
If ws.Cells(i, 1) <> "" Then
With ws.Range(ws.Cells(i, 1), ws.Cells(i, 1))
ws2.Range(ws2.Cells(erow, 1), ws2.Cells(erow, 1)).Value = .Value
End With
With ws.Range(ws.Cells(i, 2), ws.Cells(i, 2))
ws2.Range(ws2.Cells(erow, 3), ws2.Cells(erow, 3)).Value = .Value
End With
With ws.Range(ws.Cells(i, 3), ws.Cells(i, 4))
ws2.Range(ws2.Cells(erow, 5), ws2.Cells(erow, 6)).Value = .Value
ws2.Range(ws2.Cells(erow, 3), ws2.Cells(erow, 7)).Interior.Color = RGB(255, 242, 204) 'Fill Colour in 3rd column
ws2.Range(ws2.Cells(erow, 1), ws2.Cells(erow, 7)).Borders.LineStyle = xlContinuous 'Add borders to 2nd column
End With
erow = erow + 1
End If
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
End Sub
响应头仍然没有获得所需的头。
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://..... (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
我在这里想念什么...