0

私の質問:レポートを実行してテキストにダウンロードするにはどうすればよいですか? BuessinessObjects では、レポートをプレーン テキスト ファイルとしてダウンロードできます。また、API のドキュメントには、レポートをさまざまな形式でダウンロードできることが示されています。これはどのように達成されますか?

それらを PDF としてダウンロードする方法:ドキュメントでは、PDF ファイルとしてダウンロードする方法が説明されています。

ViewSupport pdfViewSupport = new ViewSupport();
pdfViewSupport.setOutputFormat(OutputFormatType.PDF);
pdfViewSupport.setViewType(ViewType.BINARY);
pdfViewSupport.setViewMode(ViewModeType.DOCUMENT);

RetrieveBinaryView retBinView = new RetrieveBinaryView();
retBinView.setViewSupport(pdfViewSupport);

RetrieveData retBOData = new RetrieveData();
retBOData.setRetrieveView(retBinView);

DocumentInformation docInfo = boReportEngine.getDocumentInformation(struid, null, null, null, retBOData);
BinaryView myBOView = (BinaryView) boDocInfo.getView();
byte[] docContents = myBOView.getContent();

私が変更すると:

pdfViewSupport.setOutputFormat(OutputFormatType.PDF);
pdfViewSupport.setViewType(ViewType.BINARY);
pdfViewSupport.setViewMode(ViewModeType.DOCUMENT);

pdfViewSupport.setOutputFormat(OutputFormatType.INT_HTML);
pdfViewSupport.setViewType(ViewType.INT_CHARACTER);
pdfViewSupport.setViewMode(ViewModeType.INT_REPORT_PAGE);

次のエラーが表示されます。

org.apache.axis2.AxisFault: Binary view of such a document should be only requested with the use of ViewType.BINARY (WRE 01151)

面白いのは、ViewType を BINARY ではなく INT_CHARACTER に設定したことです...

次の行で壊れます。

DocumentInformation docInfo = boReportEngine.getDocumentInformation(struid, null, null, null, retBOData);

私がやろうとしていること:それは本当に複雑ですが、基本的には、単一の行を返し、それをレポートに印刷するだけのレポートが必要です(他には何もありません)。テキストはxmlであるため、そのレポートをテキストとしてダウンロードします別のプログラムで使用します。

どんな助けでも素晴らしいでしょう!


注:私は 3.2 サーバーで実行していますが、すぐに 4.0 にアップグレードする予定です。したがって、ソリューションが両方のバージョンで機能する場合、それは素晴らしいことです。それ以外の場合は、v4 と v3.x のソリューションも同様に素晴らしいでしょう:)

4

1 に答える 1

1

この行の問題:

RetrieveBinaryView retBinView = new RetrieveBinaryView();

だから私はこれがどのように機能するのかわかりませんが、これはあなたが探しているものです:

ViewSupport viewSupport = ViewSupport.Factory.newInstance();
viewSupport.setOutputFormat(OutputFormatType.INT_XML);
viewSupport.setViewType(ViewType.INT_CHARACTER);
viewSupport.setViewMode(ViewModeType.INT_REPORT_PAGE);

RetrieveData retBOData = RetrieveData.Factory.newInstance();

RetrieveXMLView retXMLView = RetrieveXMLView.Factory.newInstance();
retXMLView.setViewSupport(viewSupport);
retBOData.setRetrieveView(retXMLView);
DocumentInformation boDocInfo = getDocInfo(actions, retBOData);
XMLView bView = (XMLView) boDocInfo.getView();
ByteArrayOutputStream out = new ByteArrayOutputStream(bView.getContentLength());
bView.getContent().save(out);
byte[] reportBytes = out.toByteArray();
String reportInString = new String(reportBytes);

ただし、reportInStringここにレポートを表すXMLがあります。だから私がしたことは、接頭辞と接尾辞を使ってレポートから欲しいものをカプセル化することでした。したがって、たとえば、とでカプセル化すると@#$ThisIsWhatYouWant--End$#@次のようになります。

Pattern patt = Pattern.compile("(?i)@#$ThisIsWhatYouWant-(.*?)-End$#@", Pattern.DOTALL);
Matcher match = patt.matcher(reportInString);
if (match.find()) {
  return match.group(1);
}
return null;

PSこれは、3.xサーバーと4.0BOサーバーの両方で機能するはずです。

于 2012-11-09T23:03:43.487 に答える