I have a 21,000 row spreadsheet that when I use a cflocation tag <cflocation url=”#filename#”> pointing to the spreadsheet, it does not prompt to open or save the spreadsheet, it simple displays an empty page. The spreadsheet is created by a query and if I change the query to top 8000, the cflocation works. Anything over 8,000 results in the empty page.
Does anyone have a possible solution?
Hey Randy,
You can use cfheader and cfcontent to deliver the file to the user within the same request. I would recommend using spreadSheetNew which can store the sheet to a variable and then you can deliver like follows:
theSpreadsheet = spreadSheetNew(“your-columns”);
// all your code to add rows
// deliver as follows
cfheader(name=”Content-Disposition”, value=”attachment; filename=name-of-file.xls”);
cfcontent(type=”application/vnd.ms-excel”, variable=spreadSheetReadBinary(theSpreadsheet));
You can also just delivery the file you created in the physical drive as well.
In summary, looping through a query I used <spreadsheetAddRow> to populate the rows. After the query I used <cfspreadsheet> to save the spreadsheet. I then used <cflocation url=”#filename#”> which would typically prompt the user to open or save the file but in this case it doesn’t. The file itself is fine, I can open it in Excel and when I type the path in a URL, I get prompted to open or save it.
You must be logged in to post a comment.