如何使用cURL从PHP下载.xls头文件PHP文件

So, I have a PHP script (script 1) that is a basic web page that I echo some text to the user. Whenever the user loads script 1, I want to POST to a PHP script that is has these headers :

header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=EXCBOSSTesting.xls"); 
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);

I am using cURL to call the script but it isn't downloading the file like I want it to. Keep in mind the .xls file is generated once it is called, it doesn't exist as a static file on the server. Here is my code at the moment.

$url = "http://mywebsite.com/script2.php";

$fields = array(
        'foo' => 'bar',
        'user' => 'currUser'
);

$postVars = http_build_query($fields);

//open the connection
$ch = curl_init();

$user = 'example';
$pass = 'examplePass';

$headers = array("Content-Type:   application/vnd.ms-excel; charset=utf-8");

curl_setopt($ch, CURLOPT_USERPWD, $user . ":" . $pass);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);

curl_exec($ch);

// close connection
curl_close($ch);

If I go the script2's URL in my browser, it will download the .xls file and it works just fine. What am I missing here?