陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Quintiq file version 2.0
#parent: #root
Method O_OnExportStatusChanged () derived id:Method_DialogExcelExport_O_OnExportStatusChanged
{
  #keys: '[144528.1.240694106]'
  BaseType: 'Method_LibSOPImpExp_DialogExcelExport_O_OnExportStatusChanged'
  Body:
  [*
    // TO OVERRIDE. On changed of export status
    // Can be use to download Excel files to client and/or close export dialog
    if( status = LibSOPImpExp_ImportExportBase::Status_Done() )
    {
      // Retrieve the export result from server
      exportExcel := Form.O_GetAppExportObject().astype( ExportExcel );
      
      // If only 1 Excel, download to client as it is
      if( exportExcel.LibSOPImpExp_ExportExcelFile( relsize ) = 1 )
      {
        file := exportExcel.LibSOPImpExp_ExportExcelFile( relget ).Element( 0 );
        Form.DownloadExcelFile( file.BinaryContent(), file.BrokerName() ); 
      }
      else // If more than 1 Excel, zip it and download
      {
        json := JSON::Array();
        traverse( Form.O_GetAppExportObject(), astype( ExportExcel ).LibSOPImpExp_ExportExcelFile, file )
        {
          fileJson := Form.FormatJSONForPackAsZip( file.BinaryContent(), file.BrokerName() );
          json.Add( fileJson );
        }
        
        Application.DownloadArchive( 'MP_Excels_' + DateTime::Now().Format( 'YMMD' ) + '.zip', json.Build() ); 
      }
      
      Form.Close();
    }
  *]
}