Hi everyone,
I have 2 reports processing two different kinds of models and finally I want the results from the two reports in the same excel file. My idea is to at first create one excel file and add the information from the other report into it.
Is it possible to write something in an existing excel file in report/macro? Could anyone give some suggestions?
Thanks in advance.
I have tried the following code:
var docToInsert = Context.getFile("test1.xlsx", Constants.LOCATION_OUTPUT)
var myOutputObjToInsert = Context.getOutputObject("test2.xlsx", docToInsert)
output.InsertDocument(myOutputObjToInsert, false, false)
output.WriteReport();
I don't know if it really can realize what I want, but anyway, there is an error: cannot creat outputobjectCannot create document.
Hi,
just a hint: The report is executed on the server, so you do not have access to a client file that was created in a different run of another report. Also you generally do not have access to the file system on the server. These could be options:
- You write a macro that calls both reports and puts together the Excel file on the client (that does not work in the portal, as there are no macros there)
- You write a 2-in-1 report that you can call on both model types you want to process (you need to find a way for a multi-select of all models you need processed, e. g. the Find... dialogue result). Alternatively, if there is a logical link between the 2 model types the report could find the models of the second model type from the models of the first type and produce the output to two tabs of the Excel. This option seems to be the most feasible, because usually there will be some logical link between data you want to see in the same Excel file.
- You let the client upload the file from the first run in a dialog you present at the start of the report. Then you let the report add its results. Personally I would not prefer this option, because you cannot know, if this produces security issues if the client can upload anything. I have not heard of any vulnerabilities so far, but I also have not heard of anybody actually implementing such an idea. Never trust your input.
Thanks very much for your help!
Actually I already have used a macro to execute these two reports one by one. But how could I write the information from the second report into the excel file created in the first one?
Should I still use Context.getFile(...) and Context.getOutputObject(...) ? Should I add these part in macro or in the second report?
In my opinion, I maybe it's an option to use Context.getFile(...) and getOutputObject(...) in the second report so that I could directly use DefineF to add something?
Or maybe I can use InsertDocument in macro? I tried but Context.getFile("file_from_report1.xlsx") doesn't work in macro and also the second report.
Thanks again :)