August 31, 2020
CFLOCATION with an Excel SPreadsheet
Comments
(4)
August 31, 2020
CFLOCATION with an Excel SPreadsheet
Newbie 1 posts
Followers: 0 people
(4)

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?

4 Comments
2020-09-01 21:56:00
2020-09-01 21:56:00

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.

Like
2020-09-01 12:24:34
2020-09-01 12:24:34

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.

Like
2020-08-31 21:08:37
2020-08-31 21:08:37

How do you create the spreadsheet in the first place? Do you create a file in the filesystem? Is this file corrupt?

Like
2020-08-31 21:06:48
2020-08-31 21:06:48

How do you create the spreadsheet in the first place?

Like
Add Comment