Hello,
No I am not getting any errors. Everything seems to work fine until it reaches the moment where the program should generate the excel file then nothing happens (a success message should show but it is not showing and the file is not generated).
here is the code involved, and don't put too much emphasis on the Spreadsheet/Excel/Writer.php, because in order to narrow the problem I tried a simple code with fopen, and it still did not work on the website:
$directory="C:/Documents and Settings/phpLuver/";
$myFile = $_POST['fileName2'];
$zero=0;
$one=1;
$two=2;
$three=3;
//check if file name already exists or not.
if (file_exists($directory.$myFile.".xls")) {
$errors[]="the file: ".$myFile. " already exists, please enter a new name";
echo '<h1 id="mainhead">Error!</h1>
<p class="error"><font color="red" size="+1">The following error(s) occurred:<br />';
foreach ($errors as $msg) { /* Print each error. */
echo " - $msg<br />\n";
}
echo '</p><p>Please click the button to fix your errors and try again.</p></font>';
echo '<br><br><input type=button value="Back" onClick="history.go(-1)">';
}else{
chmod($directory.$myFile.".xls",'0777');
require_once 'Spreadsheet/Excel/Writer.php';
$counter=count($myarrayUpdate);
$o=5;
$counted=1;
while($o<$counter)
{
if(!empty($myarrayUpdate[$o-1]))
$myarrayUpdate[$o-1]=$counted;
if($myarrayUpdate[$o]=='N')
$myarrayUpdate[$o]='';
$o=$o+4;
$counted++;
}
// We give the path to our file here
$workbook = new Spreadsheet_Excel_Writer($directory.$myFile.".xls");
$myDate= date("m.d.y");
$ei=0;
$worksheet =& $workbook->addWorksheet('My first worksheet');
$format_bold =& $workbook->addFormat();
$format_column =& $workbook->addFormat();
$format_merge =& $workbook->addFormat();
$format_right =& $workbook->addFormat();
$format_cell =& $workbook->addFormat();
$format_merge->setAlign('merge');
$format_right->setAlign('right');
$format_right->setAlign('merge');
$format_merge->setSize(15);
$format_right->setSize(10);
$format_bold->setBold();
$format_cell->setAlign('center');
//$format_bold->setBgColor('blue');
$worksheet->setColumn(0,0,5);
$worksheet->setColumn(1,1,20);
$worksheet->setColumn(2,3,20);
$j=0;
$worksheet->write(0, 0, 'MY DELIVERY LOG',$format_merge);
$worksheet->write(0, 1, '',$format_merge);
$worksheet->write(0, 2, '',$format_merge);
$worksheet->write(0, 3,'',$format_merge);
$worksheet->setRow(0,30,0);
$worksheet->write(1, 0, 'By:'. $User.'',$format_right);
$worksheet->write(1, 1,'',$format_right);
$worksheet->write(1, 2, 'Date:'.$myDate,$format_right);
$worksheet->write(1, 3,'',$format_right);
$worksheet->setRow(1,30,0);
$worksheet->write(2, $zero, $myarrayUpdate[$j],$format_bold);
$worksheet->write(2, $one, $myarrayUpdate[++$j],$format_bold);
$worksheet->write(2, $two, $myarrayUpdate[++$j],$format_bold);
$worksheet->write(2, $three,$myarrayUpdate[++$j],$format_bold);
$worksheet->setRow(2,30,0);
++$j;
for($i=3;$i<($counter/4)+3;$i++)
{
$worksheet->write($i, $zero, $myarrayUpdate[$j],$format_cell);
$worksheet->write($i, $one, $myarrayUpdate[++$j],$format_cell);
$worksheet->write($i, $two, $myarrayUpdate[++$j],$format_cell);
$worksheet->write($i, $three,$myarrayUpdate[++$j],$format_cell);
$worksheet->setRow($i,30,0);
$j++;
}
// We still need to explicitly close the workbook
$workbook->close();
}