Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you've discovered, doing this with ColdFusion's <code>&lt;cfspreadsheet/&gt;</code> tag fails because it builds the entire document in memory, which leads to JVM OutOfMemory errors. What you need is something that buffers output to disk so you don't run out of memory. This suggests CSV, which is far easier to buffer. I imagine there are ways to do it with Excel as well, but I don't know them. </p> <p>So two options for you:</p> <ol> <li>use a Java library </li> <li>use ColdFusion's <code>fileOpen()</code>, <code>fileWrite()</code>, <code>fileClose()</code> methods</li> </ol> <p>I'll cover each in turn.</p> <h2>Java Libary</h2> <p><a href="http://opencsv.sourceforge.net/" rel="nofollow">opencsv</a> is my preference. This assumes of course you know how to setup a .jar on the ColdFusion classpath. If you do then it's a matter using its APIs to open a file and specify data for each line. It's really quite simple. Check its docs for examples. </p> <h2>ColdFusion Methods</h2> <p><em><strong>Be forewarned there be dragons here</em></strong>. </p> <p>If you are exporting numbers or strings that do not contain any double quotes or commas you can probably do this. If not, figuring out what to escape and how is why you use a library in the first place. Code is roughly as such: </p> <pre><code>&lt;!--- query to get whatever data you're working with ---&gt; &lt;cfset csvFile = fileOpen(filePath, 'read')&gt; &lt;cfloop query="yourQuery"&gt; &lt;cfset csvRow = ""&gt;&lt;!--- construct a csv row here from the query row ---&gt; &lt;cfset fileWrite(csvFile, csvRow)&gt; &lt;/cfloop&gt; &lt;cfset fileClose(csvFile)&gt; </code></pre> <p>If the query data you're working with is also large you may be dealing with a nested loop to chunk it out. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload