Terminal Screen to Office document

Green Screens Web Terminal supports extracting data from terminal screen and populating office documents like Word or Excel. All documents are created directly inside browser and thus are limited to some extent regarding browser security and sandbox limitations. Sill, for less demanding Office documents creation, web browser is all you need when using Green Screens Web Terminal.

Before we dig into technical details let us show short presentation video first.

NOTE: Only docx and xlsx Open office formats are supported. For binary formats, HLL based solutions are required.

In our previous blogs we wrote about Terminal Macro Engine and Terminal ETL Engine which are base foundations for office extract engine.

We need to add extra mapping definition to our wrkactjob.json example (from Terminal ETL Engine post) to map extracted data to Excel row/col format. Here is a sample with descriptions.

{

  // document templates to use
  "templates": {
    "default" {
       "excel": "wrkactjob.xlsx",
       "word": "wrkactjob.docx",
       "output": "wrkactjob"
     }
  },

  // excel mapping definition 
  "excel": {

      // default sheet (optional) 
      "sheet": "Sheet1",

      // object file mapping to excel sheet/cell values; 
      // if sheet not defined, default is used
      // field can have different format definition
      "fields": {
        "title": ["C1","Sheet1"],
        "date": "D3",
        "jobs": "F2",
        "time": ["F3"],
        "system": {"cell": "B3","style": {"bold": true}},
        "test1": {"row": 1, "col": 1, "sheet": "Book1","ref": "test"},
        "test2": {"cell": "G9", "sheet": "Book1","style": {"bold": true}}
      },

      // data record definitions 
      "grids": {

        "wrkactjob": {
          "sheet": "Sheet1",
          "header": ["A5","B5","C5","D5","E5","F5"],
          "detail": ["A6","B6","C6",
            {"cell": "D6", "style": {}, "type": "number"},"E6","F6"
          ],
          "total": {
            "style": {"bold": true}
          }
        },
        "wrkactjob1": {
          "ref": "wrkactjob",
          "sheet": "Sheet2",
          "header": {"row": 5,"col": 1},
          "detail": {"row": 6,"col": 1},
          "total": {"row": 16, "col": 1, "style": {"bold": true},"offset": false}
        }
      }
    }
}

Definition shown above will extract data from ETL processed screen.

{
  "title": "Work with Active Jobs",
  "system": "PUB400",
  "date": "",
  "time": "",
  "jobs": "",
  "test": "fixed data",
  "created": "4/28/2017",
  "wrkactjob": [
    ["#SYSLOAD","QSYS","SBS",0,"","","Fixed"],
    ["SYSLOAD","#SYSLOAD","ASJ", 0,"DLY-300","","Fixed"],
    ["FB400","QSYS","SBS",0,"","","Fixed"],
    ["QBATCH","QSYS","SBS",0,"","","Fixed"],
    ["PUB400USS","RZKHWORK","PJ",0,"DLY-14","","Fixed"],
    ["QBATCH2","QSYS", "SBS",0,"","","Fixed"],
    ["VEERENDRA","VEERENDRA","BCH",0,"PGM-MSG","","Fixed"],
    ["QCMN","QSYS","SBS",0,"","","Fixed"],
    ["QCTL","QSYS","SBS",0,"","","Fixed"]
  ]
}

After creating definitions and saving them to the server, Office extraction is automatically available through context menu as shown in video or through API as shown here.

Tn5250.Export.exportExcel();
Tn5250.Export.exportWord();

Full definition example can be found on our GitHub repository here. Copy files to [user]/io.geenscreens/etl directory at Green Screens Terminal Server and as shown in video, from WRKACTJOB screen select export to one of available formats.