Solved

Download excel file from Cloud

  • 29 October 2021
  • 1 reply
  • 84 views

Badge +2

Hi,

I took the exampleNFL project from the documentation and was trying to modify the input data, write it to excel sheet Output.xlsx, cross check if the data is being modified and download the same. It seems to work till cross check part but I am facing difficulty with downloading. Could you please let me know where am I going wrong with the model? I have attached the model for your reference. Also, the model needs to work on Cloud.

Thanks,

Vishwesh

 

icon

Best answer by mohansx 1 November 2021, 20:14

View original

1 reply

Userlevel 5
Badge +5

Hello @vishweshpatil ,

 

The problem is in your pr_Download procedure. It seems like you copy-pasted the below codeblock from some other project -

 

    pro::RetrieveFileFromCentralStorage(

        storagePath :  sp_PublicDataExchangeFilename, 

        localPath   :  sp_FileProcessSpecificFileName) ;

 

Few comments regarding having this codeblock:

  1. This function retrieves a file from the PRO central storage and thus will work only when running from AIMMS PRO or Cloud. 
  2. It does not fit in the workflow that you’re trying to achieve. If you want to simply download the “Output.xlsx” then you don’t need this function. You are generating the Output.xlsx file in the AIMMS project itself and thus it is right there. It is not present in the PRO central storage for you to retrieve.
  3. It is good to enclose these functions in an IF block using ProjectDeveloperMode() or pro::GetPROEndpoint. See Develop Multi-Platform Applications — AIMMS How-To

 

Modify your pr_Download procedure as below and it will work (on Cloud too). Reference documentation is here: Download Widget — AIMMS Documentation

 

Block

    FileLocation := "Output.xlsx";

    sp_FileProcessSpecificFileName := webui::GetIOFilePath(FileLocation);

    if not ProjectDeveloperMode() then

    ! you need to copy the file to sp_FileProcessSpecificFileName only when its on PRO

    ! when in developer mode, you create the FileLocation to be in the root folder of the project

        FileCopy(FileLocation, sp_FileProcessSpecificFileName, 1);

    !    pro::RetrieveFileFromCentralStorage(

    !        storagePath :  sp_PublicDataExchangeFilename, 

    !        localPath   :  sp_FileProcessSpecificFileName) ;

    endif;

    if fileexists(sp_FileProcessSpecificFileName) then

    StatusCode := webui::ReturnStatusCode('CREATED');

    StatusDescription := "Nice.";

    endif;

OnError err Do

    StatusCode := webui::ReturnStatusCode('ERROR');

    StatusDescription := "Oops: " + errh::Message(err) ;

    errh::MarkAsHandled(err);

    break ; ! Trick to reporting one error.

EndBlock ;

 

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator