Write Data Into Excel

Introduction

This page describes how to use Provar to write data into Excel.

Setup

First this we first need data in a variable/file that we want to write in Excel.

Then drag the Write API into your Test case from the Test APIs. Enter the parameters as follows:

  • Data: data which we need to write in Excel. It can be a file or a variable
  • Data store URL: select Excel workbook from dropdown
  • Workbook: enter workbook path
  • Worksheet: enter worksheet name
  • Sheet Mode: select from three options: ‘Replace the sheet contents’, ‘Append to the sheet content’ or ‘Update the sheet content based on a condition’

After selecting one of the three Sheet Mode options, refer to the additional steps below for your chosen option.

Option 1: Replace the sheet contents

If you set Sheet Mode to ‘Replace the sheet contents’, the list of items in the ‘Tokens’ variable will be replaced in the sheet.

After execution of the Test Case, check the sheet content:

 

Option 2: Append to the sheet content

If you set Sheet Mode to ‘Append to the sheet content’, the list of items in ‘Tokens’ variable will be added to the end of the existing content in the sheet.

After execution of the Test Case, check the sheet content:

 

Option 3: Update the sheet content based on a condition

If you set Sheet Mode to ‘Update the sheet content based on a condition’, complete the following information:

  • Match by: select ‘Match by Position’, ‘Match on Condition’ or ‘Match by Columns’
  • Value range: The range of cells that needs to updated. If nothing is specified, the entire sheet will be targeted
  • Column Names: this has two options:
    • Across the first row:  Provar will start writing from the first row
    • Down the first column: Provar will start writing from the first columns

After selecting one of the the Match by options, refer to the additional steps below for your chosen option.

Option 3.1: Match by Position

If you choose Match by Position, then in Match Locator enter the Row Number from where you want to start writing:

After execution of test case, check the sheet content:

 

Option 3.2: Match On Condition

If you choose Match on Condition, next enter in ‘Match Locator’ the condition on the basis of which you want to write data.

For example:

Here, we stored data in variable named Var where Var.Name and Var.Time will refer to the columns of the sheet. 

After execution of the Test Case, Provar will update Name as MP India and Time as IST against text “India”, based on the condition set above {Location=”India”}.

Option 3.3: Match By Columns

If you choose Match By Columns, Provar will update the data in the sheet based on columns. There are no additional instructions for this option.

Further Reading

2017-05-12T11:35:04+00:00

Leave A Comment