Import Table with Excel

To Import data in the Table row

image

  1. Write Script in Logic Service
    image

image

clr.AddReference(“EPPlus”)
from System.IO import *
from OfficeOpenXml import *
from datetime import datetime
ws = ExcelPackage(Collection.GetStream(inputs.path.ToString())).Workbook.Worksheets[1]
scriptDebugService.Submit(ScriptDebug(Message=‘Test’,Payload=ws.ToString()))

details = []
debug(‘details’, details)
for rowNo in range(2,ws.Dimension.End.Row+1):
if ws.Cells[rowNo, 1] is not None and ws.Cells[rowNo, 1] != ‘’:
detail = {}
detail[‘id’] = Guid.NewGuid().ToString()
debug(‘detail’, detail)
detail[‘Title’] = ws.Cells[rowNo,1].Value
detail[‘Result 1’] = ws.Cells[rowNo,2].Value
detail[‘Result 2’] = ws.Cells[rowNo,3].Value
details.append(detail)
debug(‘details’, details)
outputs[‘details’] = JArray.FromObject(details)

  1. Do an Activity and Information to Upload the Excel file.

Information: Import
Information Type: File

Write Backend Script

if not initial and field(‘Import’) is not None and hasChange(‘Import’) and previousFormData is not None:
if previousFormData[‘Import’] == None:
j = len(field(‘Table’))
result = Module(‘Project’).logic(‘Import’, { ‘path’: data[‘Import’][‘path’].ToString() })
details = result[‘details’]
for detail in details:
row = add(‘Table’)
row[‘Title’] = detail[‘Title’]
row[‘Result 1’] = detail[‘Result 1’]
row[‘Result 2’] = detail[‘Result 2’]
calculate()