jeeva Posted October 29, 2007 Share Posted October 29, 2007 hi frnds, i have coded for generating xl file to give the report for the user.when i generate the file at first time i have download dialog box coming and when i click on open button, its giving some cache error like ' File could not be found ' in the temporary folder. when i open that second time its opening properly in the previous file itself. here my code <?php error_reporting(1); include "GlobalCS.php"; // Functions for export to excel. function xlsBOF() { echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); return; } function xlsEOF() { echo pack("ss", 0x0A, 0x00); return; } function xlsWriteNumber($Row, $Col, $Value) { echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); echo pack("d", $Value); return; } function xlsWriteLabel($Row, $Col, $Value ) { $L = strlen($Value); echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); echo $Value; return; } $fname="Conference-Report-".date("d-m-Y"); header("Content-Type: application/ms-excel"); header("Pragma:no-cache"); //header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=" . $fname . ".xls"); // This writes all your data the .xls file header("Expires: 0"); xlsBOF(); /* Make a top line on your excel sheet at line 1 (starting at 0). The first number is the row number and the second number is the column, both are start at '0' */ //xlsWriteLabel(0,0,"List of car company."); // Make column labels. (at line 3) xlsWriteLabel(1,0,"S.No"); xlsWriteLabel(1,1,"Ref-Id"); xlsWriteLabel(1,2,"Date"); xlsWriteLabel(1,3,"Created By"); xlsWriteLabel(1,4,"Requisition For"); xlsWriteLabel(1,5,"Department"); xlsWriteLabel(1,6,"Board Room"); xlsWriteLabel(1,7,"No Of Hours"); xlsWriteLabel(1,8,"Status"); //get values $s=explode("-",$_GET['sdat']); $e=explode("-",$_GET['edat']); $sdat=$s[2]."-".$s[1]."-".$s[0]; $edat=$e[2]."-".$e[1]."-".$e[0]; $from=strtotime($sdat); $to=strtotime("+1 days",strtotime($edat)); $strweek=date("Y-m-d",$from); $strtomm=date("Y-m-d",$to); $sql="select * from conferencebooking where ReqFrom between '$strweek' and '$strtomm' and Entity=$LogonEntity ORDER BY id DESC"; $exec=$dataBase->Query($sql); $xlsRow=3; $k=1; while($dataBase->fetchRow()) { $bc=$dataBase->fetchResult("BoardRoom"); if(is_numeric($bc)) $cr=$dataBase->GetData("conferencerooms","Cname","and id=$bc"); else $cr=$bc; $Status=$dataBase->fetchResult("ReqStatus"); if($Status==1) $st="Confirmed"; else if($Status==2) $st="Pending"; else if($Status==3) $st= "Cancelled"; $hrs=$globals->GetDateTime("h:i a",$dataBase->fetchResult("ReqFrom"))." To ".$globals->GetDateTime("h:i a",$dataBase->fetchResult("ReqTo")); xlsWriteNumber($xlsRow,0,$k); xlsWriteLabel($xlsRow,1,$dataBase->fetchResult("RefId")); xlsWriteLabel($xlsRow,2,$globals->GetDateTime("d-m-Y",$dataBase->fetchResult("ReqFrom"))); xlsWriteLabel($xlsRow,3,$globals->UserDetails($dataBase->fetchResult("RequisitionBy"),"CONCAT(EmpFname,' ',EmpLname)")); xlsWriteLabel($xlsRow,4,$globals->UserDetails($dataBase->fetchResult("RequisitionFor"),"CONCAT(EmpFname,' ',EmpLname)")); xlsWriteLabel($xlsRow,5,$dataBase->fetchResult("Department")); xlsWriteLabel($xlsRow,6,$cr); xlsWriteLabel($xlsRow,7,$hrs); xlsWriteLabel($xlsRow,8,$st); $xlsRow++; $k++; } xlsEOF(); exit(); ?> any idea what I'm doing wrong? Link to comment https://forums.phpfreaks.com/topic/75173-cache-problem-while-generating-xl-file/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.