# Read Test Data from Excel

**URL:** <https://forum.katalon.com/t/read-test-data-from-excel/25229>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [May 13, 2019, 7:01pm UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229 "2019-05-13T19:01:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![umas181929](https://avatars.discourse-cdn.com/v4/letter/u/dfb087/32.png) [@umas181929](https://forum.katalon.com/u/umas181929)\
**Post date:** [May 13, 2019, 7:01pm UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/1 "2019-05-13T19:01:49Z")

</div>

Hi,

I am trying to read data from an excel file at Test case level.

I am able to read test data from excel ( from sheet 1).

I also have test data in sheet 2 of the excel file which I need to read in the same test case. How can I do this?

Please let me know.

Thanks,  
Umakant

---

<div class="post-metadata">

**Author:** ![Timo\_Kuisma](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@Timo\_Kuisma](https://forum.katalon.com/u/Timo_Kuisma)\
**Post date:** [May 13, 2019, 8:04pm UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/2 "2019-05-13T20:04:09Z")

</div>

hello,

```
depends on how your script will read excel?

read again with another sheet name as parameter
you have to implement keyword where the sheet name is used as parameter

	@Keyword
	public List<String> readExcelRows(int start, int end, String path, sheetName) throws IOException, InvalidFormatException{

		SAMPLE_XLSX_FILE_PATH = path;
            workbook = WorkbookFactory.create(new File(SAMPLE_XLSX_FILE_PATH));

		// Getting the Sheet as sheetName
		Sheet sheet = workbook.getSheet(sheetName);
```

---

<div class="post-metadata">

**Author:** ![umas181929](https://avatars.discourse-cdn.com/v4/letter/u/dfb087/32.png) [@umas181929](https://forum.katalon.com/u/umas181929)\
**Post date:** [May 13, 2019, 8:34pm UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/3 "2019-05-13T20:34:41Z")

</div>

Thanks Timo for your help!!!

I was using findTestData( ) and getValue( ) methods from katalon studio API.

below is snippet:

> ```
> WebUI.setText(findTestObject('Object Repository/Page_Login Salesforce/input_Username_username'), findTestData('Automation Test Data').getValue(
> 'UserName', 1))
> 
> ```

```
    WebUI.setEncryptedText(findTestObject('Object Repository/Page_Login Salesforce/input_Password_pw'), findTestData('Automation Test Data').getValue(
            'Password', 1))

```

If I have to use them and also read the data from another sheet, Do i need to create a custom getValue( ) method with sheet as parameter? OR does katalon studio API has a predefined method to perform this task.

Please let me know.

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [May 14, 2019, 9:19am UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/4 "2019-05-14T09:19:55Z")

</div>

Hi @umas181929

There’s no native API in katalon to help read values from different sheets. However, there’s a Read Write Excel Custom Keyword Plugin that may interest you.

[https://store.katalon.com/product/34/Read-Write-Excel-Custom-Keywords](https://store.katalon.com/product/34/Read-Write-Excel-Custom-Keywords)

Cheers !

---

<div class="post-metadata">

**Author:** ![Arnel](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/arnel/32/6360_2.png) [@Arnel](https://forum.katalon.com/u/Arnel)\
**Post date:** [May 14, 2019, 9:44am UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/5 "2019-05-14T09:44:07Z")

</div>

Hi Umakant,

Kindly see the link below… You can read in different excel sheets using this approach. . .

> [@(TEST DATA) Define specific Excel Sheets to get Excel Values](http://forum.katalon.com/t/test-data-define-specific-excel-sheets-to-get-excel-values/12290):
>
> Hi there, I’m going to share something that might help you when it comes to automation which involves excel file as your test data and defining the “SHEETS” you prefer to make your test data even more dynamic. We have a class named ExcelData but it doesn’t allow us to define what sheet the automation will penetrate. See this link for the ExcelData class for your reference: [Index (Katalon Studio API Specification)](https://api-docs.katalon.com/index.html?overview-summary.html) Meaning the ExcelData is only good for one sheet which is the default sheet. And…

Hope that helps. . . 🙂

---

<div class="post-metadata">

**Author:** ![Timo\_Kuisma](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@Timo\_Kuisma](https://forum.katalon.com/u/Timo_Kuisma)\
**Post date:** [May 14, 2019, 5:45pm UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/6 "2019-05-14T17:45:48Z")

</div>

hi you,

`I am not using Katalon excel plugin, I have implemented own excel read / write keywords to my use, with this way i’ll get just that how I will use the excel functions  
😄

---

<div class="post-metadata">

**Author:** ![Nila](https://avatars.discourse-cdn.com/v4/letter/n/b2d939/32.png) [@Nila](https://forum.katalon.com/u/Nila)\
**Post date:** [September 2, 2020, 9:17am UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/7 "2020-09-02T09:17:10Z")

</div>

Hi Thanh.  
I have read the excel file in a specific location.I have a code for that.  
Still my excel file name varies always.  
But it starts with constant number followed by varying characters.  
eg “01123\_bfkjenfkennkn.xlx”  
number 01123 is constant always.  
Pls help me how to refer this excel in my code.

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:31am UTC](https://forum.katalon.com/t/read-test-data-from-excel/25229/8 "2022-08-08T07:31:57Z")

</div>


