I got a null pointer exception whenever I had zero associations set to the FileDocument.
For example, if I was trying to export a person, then if there were zero person to FileDocument associations, I would get a null error.
It turns out that because I had my FileDocument specialization with ‘DeleteAfterDownload’ set to true, the export would only work once and then those associations were lost. I had to set ‘DeleteAfterDownload’ to false to fix it.
Note: I didn’t follow the excel exporter tutorial exactly, since I tried to save time by only setting the association to the FileDocument once, instead of setting those associations every time someone clicked the ‘export’ button like the tutorial shows.