Hi; Here is the problem. I know how to query a database and create a page that will open directly in Excel rather than in a browser. (ie. the output is formatted as .csv)
However, I have some field values that, when excel opens, I want to have them all within a single cell of the excel/csv display, BUT with within-cell line breaks. Get it?
Say I have a field value that returns something like this:
"RespChoices=1:Yes|2:No|3:Unsure"
I would like the cell to display something like this:
RespChoices=
1:Yes
2:No
3:Unsure
(there may be other cells on the same line with more or fewer response choices)
<?php
session_start();
foreach($_GET as $var=>$val) {$$var=$val;}
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$extr_date=date('mdY');
$TITLE="$SRV_".$extr_date;
header("content-disposition: attachment;filename=$TITLE.csv");
// the items/response key headers for the spreadsheet
$lines = file("".$SRV.".qst"); // Load the file into an array
$_SESSION[$SRV][item]="\"\",\"\""; // a couple of blank cells for row values that always exist
$_SESSION[$SRV][respkey]="\"respdate\",\"rowkey\"";
foreach ($lines as $key =>$value) {
if(substr($value, 0,1)=="Q") {$_SESSION[$SRV][item].=",\"$value\"";}
elseif(substr($value, 0,1)=="S"){$_SESSION[$SRV][respkey].=",\"$value\"";}
else {} // not needed
}
$_SESSION[$SRV][item].="\n";
$_SESSION[$SRV][respkey].="\n";
echo $_SESSION[$SRV][item];
echo $_SESSION[$SRV][respkey];
// the actual data
include("../data/".$SRV.".dat");
?>
Any ideas? Thanks.