I can't see why the code doesn't work, other than the file may not be there.
I do see however that you're streaming out of 'public' so you could
just link to 4000.xls and bypass using Rails (it will be quicker and
free up Rails to handle the next request)