使用 ssrs link 构建 excel 报告 - 如何传递在 excel sheet 中输入的动态日期参数
Building excel report with ssrs link - how to pass dynamic date parameters entered in excel sheet
我有 excel 使用 ssrs 报告的报告 link -
http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=01/31/2016&ToDate=03/13/2016&rs:Format=Excel。当我在宏中使用它来 运行 报告按钮单击命令时,这工作正常
Private Sub ViewReport_Click()
Workbooks.Open Filename:= _
"http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=01/31/2016&ToDate=03/13/2016&rs:Format=Excel"
ActiveSheet.Range("A8:I2000").Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=False
Windows(ThisWorkbook.Name).Activate
Range("A8").Select
ActiveSheet.Paste
End Sub
但我需要将 excel sheet 中输入的动态日期传递给 url link- 在 DTPicker 中。我怎样才能实现它?
Ecxel macro capture
您只需将电子表格中的日期读入变量并设置格式即可。然后将这些变量与 URL 连接起来。
假设您的开始日期在单元格 "A1" 中,您的结束日期在单元格 "A2" 中。
Dim fromDate As String
Dim toDate As String
fromDate = Format(Range("a1").Value, "dd/mm/yyyy")
toDate = Format(Range("a2").Value, "dd/mm/yyyy")
Workbooks.Open Filename:= _
"http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=" & fromDate & "&ToDate=" & toDate & "&rs:Format=Excel"
我有 excel 使用 ssrs 报告的报告 link -
http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=01/31/2016&ToDate=03/13/2016&rs:Format=Excel。当我在宏中使用它来 运行 报告按钮单击命令时,这工作正常
Private Sub ViewReport_Click()
Workbooks.Open Filename:= _
"http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=01/31/2016&ToDate=03/13/2016&rs:Format=Excel"
ActiveSheet.Range("A8:I2000").Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=False
Windows(ThisWorkbook.Name).Activate
Range("A8").Select
ActiveSheet.Paste
End Sub
但我需要将 excel sheet 中输入的动态日期传递给 url link- 在 DTPicker 中。我怎样才能实现它?
Ecxel macro capture
您只需将电子表格中的日期读入变量并设置格式即可。然后将这些变量与 URL 连接起来。
假设您的开始日期在单元格 "A1" 中,您的结束日期在单元格 "A2" 中。
Dim fromDate As String
Dim toDate As String
fromDate = Format(Range("a1").Value, "dd/mm/yyyy")
toDate = Format(Range("a2").Value, "dd/mm/yyyy")
Workbooks.Open Filename:= _
"http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=" & fromDate & "&ToDate=" & toDate & "&rs:Format=Excel"