0
我在使用SQL Server Reporting Services的JAVA項目中使用此SSRS-API。有了這個API,我可以訪問我的SSRS文件夾和報告,但我想知道是否可以使用Excel或PDF上傳或導出報告。SSRS使用Java以SOAP上傳報告
這裏是SSRS java類:SSRS.java
而我管理的bean:
@ViewScoped
@ManagedBean(name = "biController")
@SuppressWarnings("restriction")
public class BiController {
private final String ADDRESS = "http://SERVERNAME/reportserver/ReportService2005.asmx?wsdl";
private String[] listReports;
private SSRS ssrs;
@PostConstruct
public void init() {
try {
URL url = new URL(null, ADDRESS, new sun.net.www.protocol.http.Handler());
NTLMAuthenticator.setDefault(new NTLMAuthenticator("DOMAIN", "USERNAME", "PASSWORD"));
ssrs = new SSRS(url, "");
} catch (MalformedURLException e) {
throw new FacesException();
}
}
// This function let me have the Report's names
public void constructListOfReports(String path) {
listReports = ssrs.listReports(path);
}
public String[] getListReports() {
return listReports;
}
public void setListReports(String[] listReports) {
this.listReports = listReports;
}
}
有什麼建議?
編輯
我使用的下載功能(downloadReport)SSRS API的我上面(SSRS-API)中提到,這裏是函數的代碼:
public void downloadReport(final String path, final String filename) {
final File file = new File(filename);
final String physicalName = toPhysicalFileName(path);
info("Downloading Report with symbolic name " + path + " to " + file);
final byte[] data = _soap.getReportDefinition(physicalName);
try (final FileOutputStream out = new FileOutputStream(file)) {
out.write(data);
} catch (final IOException ioe) {
final String message = "Failed to download report with symbolic name " + path + " to " + file;
LOG.warning(message);
if (file.exists() && !file.delete()) {
throw new IllegalStateException(message + " and failed to delete temporary file", ioe);
} else {
throw new IllegalStateException(message, ioe);
}
}
}
這裏是函數,我用它來調用這個函數:
public void downloadReport() {
ssrs.downloadReport('Path/Report name', 'C:\\PATH\\TO\\A\\FOLDER\\REPORT.XML');
}
而在給定的路徑(C:/PATH/TO/A/FOLDER/REPORT.XML)我得到一個XML文件中像這樣:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="PercallAnalysisDW">
<DataSourceReference>Entrepôt de données Percall Analysis</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>3a3e3aa4-c6d6-4b44-80f0-f18a9ecd2eac</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DeliveryMarginCumuleDS">
<SharedDataSet>
<SharedDataSetReference>DeliveryMarginCumuleDS</SharedDataSetReference>
</SharedDataSet>
<Fields>
<Field Name="Date">
<DataField>Date</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Projet">
<DataField>Projet</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="LABOR_facturé">
<DataField>LABOR_facturé</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="TL_facturé">
<DataField>TL_facturé</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="Coût_total">
<DataField>Coût_total</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="DM">
<DataField>DM</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="Revenu">
<Value>=Fields!LABOR_facturé.Value + Fields!TL_facturé.Value</Value>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Tablix Name="Tablix1">
<TablixBody>
...
是的,我會說那將是可能的。 –
@BobBrinks你能告訴我怎麼樣?謝謝 –
好吧,或者在SSRS中有一個調用(從來不會使用它不會知道),它會產生PDF或Excel。或者你將不得不建立一些Java代碼或找到一個從SSRS獲取數據並將數據格式化爲PDF或Excel的庫。 –