将 SSRS 报告从 Python 导出为 PDF
Exporting SSRS Reports to PDF from Python
我正在尝试 export/print/generate 来自 Python 的 SSRS 报告。看起来 SSPYRS 应该完全符合我的要求。但是,我收到一个错误并且无法找到解决方法。
import sspyrs
try:
username= "user"
password = "pass"
params_multi = {'param1': value1, 'param2': value2, 'param3': value3}
myrpt = sspyrs.report("http://sqlserver/reportingserrver/reportsfolder/reportname", username, password, params_multi).download('PDF',fileloc)
except Exception as ex:
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
我收到以下错误:
Report Server does not allow usable data export methods. Update server settings/version to enable XML, Excel, or CSV export.
当我 运行 来自浏览器的相同报告时,一切正常。我也可以毫无问题地从 .net 应用程序访问它。所以我怀疑这是权限问题。
我检查了 SQL 服务器上的 reportserver.config 文件,并且启用了 PDF 渲染。我不确定我还能看哪里。
任何帮助指导将不胜感激。
所以我必须使用 NTLM 身份验证才能让它在我的环境中为我工作。也许你可以使用 and/or 修改这个?我是 SQL 人,不是 python,但这里是:
import requests
from requests_ntlm import HttpNtlmAuth
#change username to your username
filename = 'C:\Users\username\Desktop\report.pdf'
#change username and password to your network login
username = "username"
password = "password"
#url needs to be the special url found by going to the ReportServer, the one with &rs:Command=Render
url = "http://reportservername/ReportServer%2fReportFolder%2fReportName&rs:Command=Render&rs:Format=PDF"
r = requests.get(url, auth=HttpNtlmAuth(username, password))
print(r.status_code)
if r.status_code == 200:
with open(filename, 'wb') as out:
for bits in r.iter_content():
out.write(bits)
这个post帮助了我:https://www.reddit.com/r/Python/comments/67xak4/enterprise_intranet_authentication_and_ssrs/
我正在尝试 export/print/generate 来自 Python 的 SSRS 报告。看起来 SSPYRS 应该完全符合我的要求。但是,我收到一个错误并且无法找到解决方法。
import sspyrs
try:
username= "user"
password = "pass"
params_multi = {'param1': value1, 'param2': value2, 'param3': value3}
myrpt = sspyrs.report("http://sqlserver/reportingserrver/reportsfolder/reportname", username, password, params_multi).download('PDF',fileloc)
except Exception as ex:
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
我收到以下错误:
Report Server does not allow usable data export methods. Update server settings/version to enable XML, Excel, or CSV export.
当我 运行 来自浏览器的相同报告时,一切正常。我也可以毫无问题地从 .net 应用程序访问它。所以我怀疑这是权限问题。
我检查了 SQL 服务器上的 reportserver.config 文件,并且启用了 PDF 渲染。我不确定我还能看哪里。
任何帮助指导将不胜感激。
所以我必须使用 NTLM 身份验证才能让它在我的环境中为我工作。也许你可以使用 and/or 修改这个?我是 SQL 人,不是 python,但这里是:
import requests
from requests_ntlm import HttpNtlmAuth
#change username to your username
filename = 'C:\Users\username\Desktop\report.pdf'
#change username and password to your network login
username = "username"
password = "password"
#url needs to be the special url found by going to the ReportServer, the one with &rs:Command=Render
url = "http://reportservername/ReportServer%2fReportFolder%2fReportName&rs:Command=Render&rs:Format=PDF"
r = requests.get(url, auth=HttpNtlmAuth(username, password))
print(r.status_code)
if r.status_code == 200:
with open(filename, 'wb') as out:
for bits in r.iter_content():
out.write(bits)
这个post帮助了我:https://www.reddit.com/r/Python/comments/67xak4/enterprise_intranet_authentication_and_ssrs/