Skip to: Site menu | Main content

Email Facebook LinkedIn Twitter Google

Blog...

CFSPREADSHEET action="write" java.lang.NullPointerException error

Came across some odd CFSPREADSHEET behavior in ColdFusion.

I was attempting to quickly export a query object to an Excel spreadsheet:

<cfset tmpXLSFile = "#getTempDirectory()#data_export.csv">
<cfspreadsheet action="write" overwrite="true" filename="#tmpXLSFile#" query="exportData">

ColdFusion kept throwing this strange error:

An exception occurred while using action=write. java.lang.NullPointerException

Everything seemed ok with my code and my query.

After some head scratching I noticed that my file variable had a .CSV extension. Changing this to XLS fixed the issue immediately:

<cfset tmpXLSFile = "#getTempDirectory()#data_export.xls">
<cfspreadsheet action="write" overwrite="true" filename="#tmpXLSFile#" query="exportData">

Not sure why ColdFusion cares about the file extension.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Thanks for posting this, just what was needed to resolve it for us too.
# Posted By Ken | 10/21/16 10:50 AM