Quantcast
Channel: SCN : Unanswered Discussions - BI Platform
Viewing all articles
Browse latest Browse all 5661

Converting VBA code to Java with equivalent APIs

$
0
0

Hi,

I have the following code that is in VBA that I would like to convert to Java with equivalent APIs.  What I mean is I want the program in Java to behave the same as that of the program in VBA code.  What it does is:

1) Open a document.

2) Add a filter variable - this is for sectioning.

3) Add a complex filter - this is to pull the content that belongs to the filtering (i.e employee Id).

4) Save the content to a file based on the filtering value and format.

I have been searching for in this forum to see any APIs that can do the same in Java, but I could not find anything.  Currently the VBA code processes Deski doucment and I want to do the same and Webi in Java.  Please help.  Thanks!  Code snippet in VBA enclosed below:

 

    Set myFilterVar = mydoc.DocumentVariables(in_filter_var)

    Set myFilterVarValueName = mydoc.DocumentVariables.Add("Value", "Filter_Value")

   

    If myFilterVar.ValueCount > 0 Then

        intNumChoices = UBound(myFilterVar.Values(boUniqueValues))

        'collect the number of choices in a variant variable

        myFilterChoices = myFilterVar.Values(boUniqueValues)

     

        For i = 1 To intNumChoices

   'Get the variable value

   strNextValue = Replace(myFilterChoices(i), "'", "")

       

   For j = 1 To TabCount

    Set myrpt = mydoc.Reports(j)

    'build filter

    If IsNumeric(myFilterChoices(i)) Then

     myrpt.AddComplexFilter myFilterVar, "=<" & myFilterVar.Name & "> = ToNumber(<" & myFilterVarValueName.Name & ">)"

    Else

     myrpt.AddComplexFilter myFilterVar, "=<" & myFilterVar.Name & "> = " & """" & strNextValue & """"

    End If

   

    myFilterVarValueName.Formula = strNextValue

    'recompute the report

    myrpt.ForceCompute

   Next j

           

   'now export to desired format, using the filter value as part of the name

   If g_report_file_type_id = pdf Then

    mydoc.SaveAs (lDir & mydoc.Name & "-" & strNextValue & ".pdf")

   ElseIf g_report_file_type_id = xls Then

    mydoc.SaveAs (lDir & mydoc.Name & "-" & strNextValue & ".xls")

   ElseIf g_report_file_type_id = both Then

    mydoc.SaveAs (lDir & mydoc.Name & "-" & strNextValue & ".pdf")

    mydoc.SaveAs (lDir & mydoc.Name & "-" & strNextValue & ".xls")

   End If       

        Next i

    End If


Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>