admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
StaticMethod Download (
  MacroPlan macroPlan,
  OfflinePlanRows selectedOPRs
) as BinaryValue
{
  TextBody:
  [*
    xmlDOMI      := XMLDOMImplementation::Create();
    xmlDOM       := xmlDOMI.CreateDocumentFromString( '<?xml version="1.0" encoding="UTF-16"?><table><name>Sheet1</name></table>' );
    
    tableElement := xmlDOM.GetElementByTagName( "table", 0 );
    
    opt  := maxselect( macroPlan, OfflinePlanTable, tempOPT, true, tempOPT.SaveDateTime() );
    opcs := selectsortedset( opt, OfflinePlanColumn, tempOPC, true, tempOPC.ColumnDate() );
    oprs := selectsortedset( selectedOPRs, Elements, tempOPR, true, tempOPR.ProductionLine(), tempOPR.ProductID(), tempOPR.Type() );
    traverse ( opcs, Elements, opc ) {
      column := xmlDOM.CreateElement( "column" );
      name   := xmlDOM.CreateElement( "name" );
      type   := xmlDOM.CreateElement( "type" );
      name.TextContent( ifexpr( opc.ColumnDate() < macroPlan.StartOfPlanning().Date(), "*", opc.ColumnDate().Format( "Y/M2/D2" ) ) );
      type.TextContent( "String" );
      column.AppendChild( name );
      column.AppendChild( type );
      
      traverse ( oprs, Elements, opr ) {
        c    := select( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow() = opr );
        cell := xmlDOM.CreateElement( "cell" );
        cell.SetAttribute( "value", guard( c.Value(), "" ) );
        column.AppendChild( cell );
      }
      
      tableElement.AppendChild( column );
    }
    
    xmlString := xmlDOMI.CreateSerializer().WriteToString( xmlDOM )
    
    //info( xmlString );
    
    tableGroupHandle := TableGroupHandle::Create( "Sheet1" );
    tableHandle      := TableHandle::ImportXML( BinaryValue::Construct( xmlString ) );
    tableGroupHandle.Add( tableHandle );
    
    binaryData := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
    
    return binaryData.AsBinaryValue();
  *]
}