Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

have an example of Cobol reading EXCEL? 1

Status
Not open for further replies.

ironponygrl

Programmer
Jun 18, 2003
1
0
0
US
I'm looking for an example of a COBOL program reading an excel spreadsheet. I'm using MicroFocus Cobol and they don't have a readily available example. I've never worked with OLE, but I'm sure I can manage if I can just get pointed in the right direction. The example at microfocus website shows creating and writing to the spreadsheet, not opening an existing one and reading it. thanks
 
Hi,

a very easy way to work with excel is using the format SYLK with the extension SLK. It is ASCII so it is easy to read, write, etc. It has almost all functionality of the complete worksheet. Only some minor things are not within the SYLK standard but that can not be a problem. Also a little macro in Excel can solve those small problems.

Also: the SYLK format is up- and downwards compatible. Unbelievable? Yes, almost. But I can read on my very old Tandy TRS80 model 100 with an Excel ROM in it (I bought it in 1984/5), the SYLK output from a current Excel version. Of course, not all functionality is there but what it can understand, it does. The current Excel program understands perfectly the old SLK files. No problem.

Also: save as SLK and start your COBOL program, wait for it to finish and reload the SLK can be in Office Basic/VBA/macro's.

Give it a try. You will like it.It is easy and also version independent!

Regards,

Crox
 
If you're relatively comfortable with using ActiveX objects in COBOL, you can use ADO to read it. Here's a sample connection string in VB that you can convert to COBOL:
Code:
Dim oConn As New ADODB.Connection
With oConn
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .Properties("Extended Properties").Value = "Excel 8.0"
    .Open "C:\Book1.xls"
    '....
    .Close
End With
[\code]
This will allow you to work with the data using ADO recordsets.

Regards.

Glenn
 
Save the EXCEL spreadsheet as a comma-delimited file (the extension is ".csv"). Then simply read it, parsing out each field based on the commas. If the COBOL program is on the same platform as the spreadsheet file, just point the program to that file. If the COBOL program is on a mainframe or any other platform, then you would need to FTP the file to that platform
 
With CSV files, you only have the data, not the instructions. With SYLK you have data, instructions, lay-out and macro's.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top