Currently there is no way to know what columns are shown in the grid, but all the fields, even if now showing, are available from the scripts environment. Take a look to the "Export metadata to MS Excel or OpenOffice Calc" sample script.
If the goal is to only export the visible in the grid, then this info needs to be made available. I will look into this.