What I'm trying to do is
A User puts in a Date They press a Download Button, this runs a query generating the results for the date they entered. While doing this it is writing these files to my server as .CSV. I will end up zipping them and the file will start downloading as a zip.
I have the code working to write the query to our server but my problem is it puts it all into one big file, where I would like to have the results separated in 2000 results per file. Is this possible? If so how do I go about this?
Current code I have for the query and writing data to server. Some things adjusted.
<cfquery name="users" datasource="#request.db#">
SELECT DISTINCT firstname
FROM Users
WHERE Users.Date=#Date#
</cfquery>
<cfset filePath="D:/Users/Users.csv">
<cfset content = "firstname">
<cffile
action="write"
file="#filePath#"
output="#content#">
<cfoutput query="users">
<cfset content = "">
<cfset content = "#firstname#">
<cffile
action="append"
file="#filePath#"
output="#content#">
</cfoutput>
<cfheader name="Content-Disposition" value="attachment; filename=#getFileFromPath (filePath)#">
<cfcontent file="#filePath#" type="application/octet-stream" deletefile="yes">
This code will run the query, writing the file to server and automatically download. But only downloads and writes to one file. How do I separate it into multiple small result files?
<cfzip>and then do theContent-Dispositionpart on the resulting zip filexlsx/<cfspreadsheet>is an option. xlsx files are naturally zipped.