I've been using the code below to successfully create spreadsheets for a few years. Now I have the need to insert page breaks at random times. I haven't found any code that does that without having to abandon this code and installing something completely different which I'd rather not do. This code is very simple and effective. Anyone know how? If it's easier creating a new worksheet that would be fine. Thanks in advance.
for ($y = 0; $y <= $totline; $y++) {
$value = trim($fnames[$y]);
if ((!isset($value)) OR ($value == ""))
{$value = "\t";}
else
{$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";}
$line .= $value;
}
$header = trim($line);
$line = " ";
for ($x = 1; $x <= $totrows; $x++) {
$rowarr = $arrin[$x];
$result = strpos($rowarr[0], "-");
if ($showroom == "yes" or $result === false) {
for ($y = 0; $y <= $totline; $y++) {
$value = trim($rowarr[$y]);
if ((!isset($value)) OR ($value == ""))
{$value = "\t";}
else
{$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";}
$line .= $value;
}
$data .= trim($line)."\n";
$line = " ";
}
}
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
$filename = "payroll_" . date('Ymd') . ".xls";
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
print "$header\n$data";
?>