hongji.li
2023-11-11 df5a7e1ad6835e78b2f9eb7428817b0c23b116bc
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Quintiq file version 2.0
#parent: #root
Method ExportAll () id:Method_ApplicationLibMacroPlanner_ExportAll
{
  #keys: '[108486.0.1580753051]'
  Body:
  [*
    //Export xls files to specified location
    path := Application.GetSaveFileName();
    
    if( path <> '' )
    {
      pos := 0;
      last := 0;
    
      while( pos > -1 )
      {
        last := pos + 1;
        pos := path.FindString( '\', last );
      }
    
      path := path.SubString(0, last );
    }
    
    importbrokers := selectset( Domain,
                                EDIDefinitionManager.BrokerDefinitions,
                                broker,
                                broker.Name().LikeUserLocale( 'MP_Import' ) );
    
    if( path <> '' )
    {
      traverse( Domain,
                EDIDefinitionManager.BrokerDefinitions,
                broker,
                broker.Name().LikeUserLocale( 'MP_Export' ) )
      {
    
        //find corresponding import broker
        importbrokername := broker.Name().ReplaceAll( 'MP_Export', 'MP_Import' );
        importbroker := select( importbrokers, Elements, e, e.Name() = importbrokername );
    
        xlsname := broker.Name().SubString( 9, broker.Name().Length() - 15 ) + '.xlsx';
        if ( not isnull( importbroker ) )
        {
          xlsname := importbroker.Source().astype( EDIXLSLinkDefinition ).FileName();
        }
    
        filename := path + xlsname;
    
        mdsdefinition := broker.MDSDefinition();
        mdshandle := this.MDSHandle(mdsdefinition.Name())
    
        clientfile := Application.GetClientFile( filename );
    
        data := broker.GetFullDestinationData(mdshandle.MDSID().MDSKey());
    
        tablegroup := TableGroupHandle::Create(data);
        XLS::SaveTableGroup( tablegroup, clientfile.LocalFileName(), true )
    
        Application.TransferToClient(clientfile);
        Application.RemoveLocalCopy(clientfile);
    
      }
      info('xls file exported to:', path );
    }
  *]
}