# Read an Excel spreadsheet

**URL:** <https://techcommunity.softwareag.com/t/read-an-excel-spreadsheet/97309>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Code-Samples\
**Created:** [June 2, 2011, 3:00am UTC](https://techcommunity.softwareag.com/t/read-an-excel-spreadsheet/97309 "2011-06-02T03:00:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [June 2, 2011, 3:00am UTC](https://techcommunity.softwareag.com/t/read-an-excel-spreadsheet/97309/1 "2011-06-02T03:00:58Z")

</div>

Does anyone have any code which will read the values from a cell or a range of cells in an Excel spreadsheet. I have seen code in this Forum which will write to a cell but I cannot get a “Read” to work.

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [June 2, 2011, 11:14pm UTC](https://techcommunity.softwareag.com/t/read-an-excel-spreadsheet/97309/2 "2011-06-02T23:14:02Z")

</div>

I would perform an intermediate step and copy the XLS to a CSV file. You can name it ‘.CSV’ or ‘.TXT’. Then a simple READ WORK does the trick.

```auto
DEFINE DATA LOCAL
1 #WORK
  2 #A (A3)
  2 #B (A3)
  2 #C (A3)
  2 #D (A3)
  2 #E (A3)
1 #CSV (A250) INIT <'c:\csv.txt'>
END-DEFINE
DEFINE WORK FILE 5 #CSV TYPE 'CSV'
READ WORK 5 #WORK
  DISPLAY #WORK
END-WORK
END
```

Actually, the real trick is TYPE ‘CSV’ in the DEFINE WORK statement.

In the Configuration Utility, you can set the delimiter character (comma, semi-colon, or tab) and specify whether there is a header line.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [June 2, 2011, 11:34pm UTC](https://techcommunity.softwareag.com/t/read-an-excel-spreadsheet/97309/3 "2011-06-02T23:34:39Z")

</div>

I could do that but then I would need to import the modified CSV file back into a spreeadsheet. Not difficult I guess. But I have the code to write directly into an Excel spreadsheet - I am so close but cannot get a Read to work for some reason. I need to read certain cells and then write to a cell where I found a specific value.

The CSV file will be my Plan “B”.

Thanks for the info.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:00pm UTC](https://techcommunity.softwareag.com/t/read-an-excel-spreadsheet/97309/4 "2021-04-02T15:00:21Z")

</div>


