Hi All,
I am trying to use indexing for type " List of Text String " but the output i am getting not the expected output i am adding the screenshots here for reference.
Thanks In advance,
SSP
Discussion posts and replies are publicly visible
Can you share your code? I am sure I understand what you do and what your goal is.
Hi Stefan,Here is my code.
a!localVariables( local!exceldata: readexcelsheet( excelDocument: cons!IT_SAMPLE_FILE, sheetNumber: 0, startRow: 0, /*stopReadingAtFirstBlankRow: false(),*/ /*pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 0)*/ ), local!datalength: length( index(local!exceldata, "result", "values", {}) ), local!headers: index(local!exceldata, "result", "values", 1, {}), local!filecdt: a!forEach( items: local!headers[1], expression: { fv!item & " : " & a!forEach( items: 2, /*enumerate(local!datalength - 1) + 2,*/ expression: a!forEach( items: index( local!exceldata, "result", "values", fv!item, {} ), expression: a!forEach( items: fv!item, expression: a!forEach( items: fv!item, expression: fv!item ) ) ) ) } ), local!filecdt )
IN the code you provided, you are using some excel file. What you want to get from that and what is there in that file.
I am trying to create a dynamic excel reader and use the data in a grid.
Oh you want to create a grid based on dynamic Excel. Let me write the code and will let you know ASAP.
a!localVariables( local!excelData: index(readexcelimportfile( excelDocument: todocument(57745), /*put excel document id instead of 57745*/ sheetNumber:0, startRow:0 ),"result",{}), a!gridField( data: remove(local!excelData,1), columns: { a!forEach( items: local!excelData[1].values, expression: a!gridColumn( label: fv!item, value: index(fv!row.values,fv!index,{}) ) ) } ) )
Please refer this code and see if it works.
a!localVariables( local!exceldata, a!sectionLayout( contents: { a!fileUploadField( label: "Upload a File :", target: cons!IT_FOLDER, fileNames: "File Reading-File Uploaded on " & text(now(), "ddmmyyhhmmss"), fileDescriptions: "File Reading Interface Testing on File Uploaded on " & text(now(), "ddmmyyhhmmss"), maxSelections: 1, value: ri!uploadedFile, saveInto: { ri!uploadedFile, a!save( local!exceldata, index( readexcelsheet( excelDocument:todocument(ri!uploadedFile), sheetNumber:0, startRow: 0 ), "result", {} ) ) }, required: true(), validations: if( contains({ "csv", "xlsx" }, fv!files.extension), {}, "Only CSV,XLSX formats files should be uploaded but uploaded file is of format ." & fv!files.extension ) ), a!gridField( label: "Excel Data :", emptyGridMessage: "Please Upload a File with Values", data: remove(local!exceldata, 1), columns: a!forEach( items: local!excelData[1].values, expression: a!gridColumn(label: fv!item, value: index(fv!row,fv!index,{})) ), showWhen: not(a!isNullOrEmpty(ri!uploadedFile)) ) } ) )
It is returning blank because the file is not in Appian System. you are just uploading it and the uploaded file will be in Appian system once you click on submit button. Make Sure, the interface where you are uploading the file is either a start form of the process model or a user input task.
Just to check the code, you can manually upload the excel into Appian and copy the id of that document and put it into excelDocument configuration of the ReadExcelSheet function.
Thank you will check that
a!localVariables( local!uploadedFile, local!exceldata, a!sectionLayout( contents: { a!textField( value:local!uploadedFile, saveInto: { local!uploadedFile, a!save( local!exceldata, index( readexcelsheet( excelDocument:todocument(57745), /*57745 is the document id. Please replace it with yours*/ sheetNumber:0, startRow: 0 ), "result", {} ) ) } ), a!gridField( label: "Excel Data :", emptyGridMessage: "Please Upload a File with Values", data: remove(local!exceldata, 1), columns: a!forEach( items: local!excelData[1].values, expression: a!gridColumn(label: fv!item, value: index(fv!row.values,fv!index,{})) ), showWhen: not(a!isNullOrEmpty(local!uploadedFile)) ) } ) )
Please refer the above code
Yes your correct but it won't work when you reading the data from Excel as the data type is like (list of list of.. variants), try to get the values using different index and take separate local variables for each index output.
This seems like that this is a list of lists where each sub-list contains one text. Then trying to index the first item will basically return the first character of each text. a!flatten() is made to solve this kind of issue. Then your approach will work.