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
Quintiq file version 2.0
#parent: #root
Method ImportFromXLS (String brokerID_i, String dataTransformationID_i, Boolean doSynchronize_i) as Boolean id:Method_LibDIF_GlobalState_ImportFromXLS
{
  #keys: '[146730.0.583908152]'
  Body:
  [*
    // Import data from XLS.
    success := false;
    
    // Ask the user for the filename.
    filename := Application.GetOpenFileName( "xlsx" );
    
    if( filename <> "" )
    {
      // Make sure that the Integration-dataset is selected.
      if( this.EnsureIntegrationDataset() )
      {
        // Convert the BinaryData to a BinaryValue so it can be passed to the Server.
        xlsData := Application.ReadBinaryFile( filename ).AsBinaryValue();
    
        // Call the import broker to import the data as integration objects.
        // Synchronize the data if applicable.
        api := this.GetIntegrationAPI();
        if( not isnull( api ) )
        {
          if( doSynchronize_i )
          {
            api.ImportFromXLSAndSynchronize( xlsData, brokerID_i, dataTransformationID_i );
          }
          else
          {
            api.ImportFromXLS( xlsData, brokerID_i, dataTransformationID_i );
          }
    
          success := true;
        }
      }
    }
    
    return success;
  *]
}