Converter (Table to Excel-CSV)

Stores the values in a Table type data item into a File type data item as an Excel compatible CSV.

    A. Select TABLE DATAData selectTableRequired
    B. Set COL IDs for Extraction (e.g. "0,1,5,3,6")Single-line inputRequired
    C. Select STRING DATA for File NameData selectString(single line)Required
    D. Select FILE DATA (update)Data selectFileRequired
    -variable namevariable label
    Aconf_DataIdASelect TABLE DATA
    Bconf_ColIdsSet COL IDs for Extraction (e.g. "0,1,5,3,6")
    Cconf_DataIdCSelect STRING DATA for File Name
    Dconf_DataIdDSelect FILE DATA (update)
    // Converter from Table to Excel-CSV (ver. 20161122)
    // (c) 2016, Questetra, Inc. (the MIT License)
    
    //// == 自動工程コンフィグの参照 / Config Retrieving ==
    var dataIdA = configs.get( "conf_DataIdA" );
    var colIds = configs.get( "conf_ColIds" ) + "";
    var dataIdC = configs.get( "conf_DataIdC" );
    var dataIdD = configs.get( "conf_DataIdD" );
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    var myTable = data.get( dataIdA );
    // myTable: com.questetra.bpms.core.model.formdata.ListArray
    var fileName = data.get( dataIdC ) + "";
    
    //// == 演算 / Calculating ==
    if( myTable !== null){
      var colIdArray = colIds.split(",");
      var numOfCols = colIdArray.length;
      var numOfRows = myTable.size() - 0; // 行(Tableの高さ)
    
      var myTsv = "";
      for( var i = 0; i < numOfRows; i++ ){
        for( var j = 0; j < numOfCols; j++ ){
          myTsv += myTable.get(i, parseInt( colIdArray[j] ) ) + "";
          if( j != numOfCols - 1 ){
            myTsv += "\t";
          }
        }
        if( i != numOfRows -1 ){
          myTsv += "\n";
        }
      }
    
      var csvFiles = new java.util.ArrayList();
      csvFiles.add(
        new com.questetra.bpms.core.event.scripttask.NewQfile(
          fileName,
          "text/tab-separated-values; charset=x-UTF-16LE-BOM", 
          myTsv
        )
      );
    }
    
    //// == ワークフローデータへの代入 / Data Updating ==
    retVal.put( dataIdD, csvFiles );
    

    • A’: Table information stored in the Data Item selected at config A
    • The value of each cell of table A’ will be stored in the Data Item selected in config B as an Excel-compatible CSV file.
    • It is also possible to change the order of columns, filter columns, list columns duplicately etc.
    • The file entity consists of tab-separated-values (utf-16le-bom)
    • The SJIS version consists of comma-separated-values. Although the availability of smartphone display and data import increases, comma information misses.