Read an Excel spreadsheet

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.

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.

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.

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.