Ask a Question

Adding data stored in different variables in various scripts into one spreadsheet.

SOLVED
nedbacan
Frequent Contributor

Adding data stored in different variables in various scripts into one spreadsheet.

I have different scripts that capture data from different on-screen label element of the application and assign it to a global variable.

How can I get them all into one Spreadsheet? 

Would I need to make a new script to call each variable and add them to the spreadsheet, or does TC has a Log.SaveToFile method to use within each script to log the data from the variables into the same spreadsheet. 

 

 GetPatientID is retrieved from scripts one

GetPatientName is retrieved from script two

GetPatientDOB is retrieved from script three 

 

Can someone show me an example of how to do this. Thank you.

 

1 REPLY 1
rraghvani
Valued Contributor

See Excel Object, and it will be something similar to this

function PatientDetails()
{
    // Get the sheet of the Excel file
    var excelFile = Excel.Open("C:\\Temp\\PatientDetails.xlsx");
    var excelSheet = excelFile.SheetByTitle("Sheet1");
      
    // Write the obtained data into a new row of the file
    var rowIndex = excelSheet.RowCount + 1;
    excelSheet.Cell("A", rowIndex).Value = // GetPatientID;
    excelSheet.Cell("B", rowIndex).Value = // GetPatientName;
    excelSheet.Cell("C", rowIndex).Value = // GetPatientDOB;
    excelFile.Save();
}
cancel
Showing results for 
Search instead for 
Did you mean: