Здесь я пытаюсь отформатировать Excel с помощью PHP-Spreadsheet / Excel / Writer.php, я вижу сбойные данные в Excel после их загрузки. Ниже приведен снимок экрана изображения. У меня есть Googled и попробовал пару решений. Все то же самое может любой, пожалуйста, помогите мне найти решение
<?PHP
session_start();
include_once('database/Insert.php');
include_once('database/Select.php');
header("Content-Type: application/vnd.ms-excel");
header('Cache-Control: max-age=0');
$filter= $_SESSION['filter'];
function vendor($crdid){
$contract_renewal_data = array();
$getVendor= new Select;
//echo $crdid;
$crdidarray=explode(",",$crdid);
$string="";
for($d=0;$d<count($crdidarray);$d++){
$contract_renewal_data = $getVendor->selectWhere('contract_renewal_data','crdid',$crdidarray[$d]);
if($contract_renewal_data != null){
if(count($crdidarray)>$d+1){
$string .= "".str_replace(",",".",$contract_renewal_data[0]['vendor'])." ; ";
}else{
$string .= "".str_replace(",",".",$contract_renewal_data[0]['vendor'])."";
}
//echo $string;
}
}
return $string;
}
require_once 'Spreadsheet/Excel/Writer.php';
try{
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8);
$format_bold =& $workbook->addFormat();
$format_bold->setBold();
$format_title =& $workbook->addFormat();
$format_title->setBold();
$format_title->setColor('white');
$format_title->setBgColor('#9CF');
$worksheet =& $workbook->addWorksheet();
$worksheet->setInputEncoding('UTF-16LE');
// While we are at it, why not throw some more numbers around
$worksheet->write(0, 0, "S No", $format_title);
$worksheet->write(0, 1, "Account Name", $format_title);
$worksheet->write(0, 2, "Account Industry", $format_title);
$worksheet->write(0, 3, "Capgemini Sector", $format_title);
$worksheet->write(0, 4, "Incumbent SBU", $format_title);
$worksheet->write(0, 5, "Name of Incumbent Vendors", $format_title);
$worksheet->write(0, 6, "Account Attractiveness Score", $format_title);
$worksheet->write(0, 7, "Cagpemini Positioning Score", $format_title);
for($i=0;$i<count($filter);$i++){
$worksheet->write($i+1, 0, ($i+1));
$worksheet->write($i+1, 1, $filter[$i]['account_name']);
$worksheet->write($i+1, 2,$filter[$i]['account_industry']);
$worksheet->write($i+1, 3,$filter[$i]['cg_sector']);
$worksheet->write($i+1, 4,$filter[$i]['Incumbent_SBU']);
$worksheet->write($i+1, 5,vendor($filter[$i]['crdid']));
$worksheet->write($i+1, 6,$filter[$i]['CI_in_senario1']);
$worksheet->write($i+1, 7,$filter[$i]['CG_in_senario1']);
}
$workbook->send('Executive Dashboard.xls');
$workbook->close();
exit();
}catch(Exception $e)
{
// $this->isConnected = false;
echo "error is ".$e->getMessage();
throw new Exception($e->getMessage());
}
?>
Задача ещё не решена.
Других решений пока нет …