Report-Output to two files

Translate this pagebookmark or share this page
Dominik's picture

Posted: 2012-05-03
1037 views | 6 comments | category: ARIS Support

5
show all articles

Hi

In my report, I'm running trough big arrays. Each entry (a model) creates a new sheet (Excel-Report).

Now I have to to the same loop again, because I need the same but with other columns.

What I like to to is, that I have one report and creating the output to each proper outputfile.

I can create the two OutputObjects and also fill the content correctly. But at the end, Aris will open Excel only with one report (the last). As I understand, this is defined by the report-path (including one filename) in the Report-Assistant-Dialogue.

But I do also the following:

oOutDef.WriteReport("C:\\Temp","temp.xls")

This runs witout error, but the file is not there.

What did I miss or how to write multiple files in one report?

Kind regards,

Dominik

Comments
Jens's picture

Hi Dominik,

try to use:

 

Report class Context - Method addOutputFile

 

addOutputFile ( String p_sFileName, byte[] p_fileData )

Adds the specified file to list of files to be transfered to the client.  

 

Cheers,

Jens 

Dominik's picture

Hi Jens,

thanks for this.

I get an TypeError, saying that this function cannot be found.

And second, how can I put the Data into p_fileData?

What I have is:

var oOutDef = Context.createOutputObject()
oOutDef.OutputF("blabla", getString("ID_STYLE_RD_DEFAULT"))
oOutDef.WriteReport()

This works with opening Excel. With your Info, I tried this:

var oOutDef = Context.addOutputFile("text.xls",p_fileData)
oOutDef.OutputF("blabla", getString("ID_STYLE_RD_DEFAULT"))
oOutDef.WriteReport()

 

Jens's picture

Hi Dominik,

in this case I think

 

addOutputFileName ( String p_sFileID, int p_nLocation )

 

is better. You have to do the following:

 

1. Create a output object with a given filename

var out = Context.createOutputObject ( Constants.OUTEXCEL,  filename );

2. Add some content

out.OutputF("blabla", getString("ID_STYLE_RD_DEFAULT"));

3. Add the output file to transfer

Context.addOutputFileName(filename, Constants.LOCATION_OUTPUT);  

 4. Call WriteReport

out.WriteReport( Context.getSelectedPath(), filename );

 

 

Jens

 

 

Dominik's picture

Hi Jens,

Thanks. It almost works. Im running in trouble with the 4th statement.

When I read the ARIS help to the WriteReport(String,String)-Statement, there is documented, that the first parameter (p_sSelectedPath) will be ignored. This fits the current error. The report does not try to save the report where I like, he chooses "D:\ARIS7.2\server\temp\ReportTemp\5\text.xlsx. This is a directory that does not exist on the client. This is the server-directory, and none of the users later have access to this share. Even when the file will be stored there. They can't get the report by file-explorer.

So, how can the correct place be defined?

I have a var for this:

var selClientFolders = Dialogs.getClientFolder("Select new output folder", "", false)

What can be done?

Dominik

Jens's picture

Here an example writing two files. Send to client in a folder selected by the user:

function main() {
    
 var out = Context.createOutputObject ( Constants.OUTEXCEL,  Context.getSelectedFile() );
 out.DefineF("F1", "ARIAL", 8, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0, 21, 0, 0, 0, 1);
 out.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_CENTER, 0); 
 out.TableRow();
 out.TableCellF("BlaBLa", 100, "F1");
 out.EndTable(" ", 100, "ARIAL", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_CENTER | Constants.FMT_VCENTER|Constants.FMT_BOLD, 0); 
 
 var filename = "secondfile.xls";
 var out2 = Context.createOutputObject ( Constants.OUTEXCEL, filename );
 out2.DefineF("F1", "ARIAL", 8, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0, 21, 0, 0, 0, 1);
 out2.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_CENTER, 0); 
 out2.TableRow();
 out2.TableCellF("BlaBLa2", 100, "F1");
 out2.EndTable(" ", 100, "ARIAL", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_CENTER | Constants.FMT_VCENTER|Constants.FMT_BOLD, 0);  
 out2.WriteReport();
 Context.addOutputFileName(filename, Constants.LOCATION_OUTPUT);
 
 var selClientFolders = Dialogs.getClientFolder("Select new output folder", "", false);
 if( selClientFolders != null ) {
    for each( folder in selClientFolders ) {
        Context.setSelectedPath( folder );
    }    
 }
 out.WriteReport();
 
}
main();
Dominik's picture

Thanks, this solution works!