How to write data to Excel file by using Access Database Engine

I have recently had to deal with a legacy Visual Basic application that writes data to Excel. It suddenly started malfunctioning (It was writing data only to the first row instead of all across the worksheet).

We solved the issue by installing the latest version of Access 2010 Database Engine. I am adding the source code here in case someone needs it.