Fixed spreadsheet export and add a test

Change-Id: I8eabf14eec370293e6af87d093dfe0ade9e1d429