Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8627

Re: Converting VBA code to Java with equivalent APIs

$
0
0

Hi,

 

I found this code that is almost able to meet my needs; however, one caveat is I do not know how to loop through each filter to pull out the section belongs to that filter and save to a file.  The filter does not seem to apply individually; I would get mixed up results and some cases no content at all.  I thought I had a solution but not yet.  Please help.  Thanks!

 

String filterObjectName = "End Key";
String filterValues = "342293745;573500167;630694746";

FilterContainer filterContainer = reportContainer.createFilter(LogicalOperator.OR);//.AND);
ReportDictionary reportDictionary = widoc.getDictionary();

ReportExpression reportExpression = reportDictionary.getChildByName(filterObjectName);
// Create a filter object on the ReportExpression
FilterObject filterObject = filterContainer.createFilterObject(reportExpression);
// Creating an IN LIST filter condition
FilterCondition filterCondition = filterObject.createFilterCondition(Operator.IN_LIST);
// Adding the values to the filter condition
String[] valueArray = filterValues.split(";");
for (int i = 0; i < valueArray.length; i++) {
filterCondition.createFilterConditionConstant(valueArray[i]);
// Apply the changes
widoc.applyFormat();
/************************** DISPLAY THE FIRST REPORT **************************/
// Refresh the Web Intelligence document
widoc.refresh();
// Retrieve the first report
Reports reports = widoc.getReports();
System.out.println(reports.getCount());
Report report = reports.getItem(0); //widoc.getReports().getItem(0);

BinaryView binaryDoc = (BinaryView) report.getView(OutputFormatType.XLS); //OutputFormatType.PDF);    
String fileName = "C:\\BoJava\\" + valueArray[i] + ".xls"; //".pdf";
File file = new File(fileName );
file.setWritable(true);
FileOutputStream fileOuputStream = new FileOutputStream(file);
fileOuputStream.write(binaryDoc.getContent());
fileOuputStream.close();
}


Viewing all articles
Browse latest Browse all 8627

Trending Articles