How to write an excel spreadsheet programmatically, assigning attributes like font, color, format, highlight
Estimated Reading Time: 1 MinutesHere are the steps to compile and run the attached sample COBOL program (in xlsx.zip) which will create an Excel spreadsheet and change the format, font, color and highlight some of the cells. This sample uses Apache POI based on the POI API documentation. We recommend using the IDE to modify this sample program. The IDE makes it easier to build a source program that uses external java libraries because the IDE Editor gets the fields and methods of the class or object reference using the IDE's "Content Assistant" facility.
- Extract the attached zip file, xlsx.zip, into a directory
- Import the project to the IDE. The project contains the sample program called xlsx.cbl
- Compile and execute the program xlsx.cbl. After the execution you will find an Excel spreadsheet called excel-file.xlsx in the project's output folder.
You can also compile and run from the command line: From the source folder run: iscc xlsx.cbl, then from the output folder run iscrun XLSX