0
我一直在使用PHP_XLSXWriter,並且我非常喜歡它的簡單性和快速性,但我無法通過電子郵件獲取格式。我已經嘗試了各種顏色格式的填充,雖然文檔似乎使用3個字符的十六進制。使用PHP_XLSXWriter向電子郵件格式化的數據發送電子郵件
這裏是生成xl格式的函數。 你可以看到,我只是想在第一行
function create_xl_string($data) {
$writer = new XLSXWriter();
$rowdata=array('dr1','rp','RoutePattern','TOD','p1','p2','p3','p4','p5','p6','p7','locNames','1D_Minutes','1D_ACD','1W_Minutes','locations','defrate','maxcost','ptLoss','projLoss','modified','description');
$rowstyle=array('fill'=>"#FC0",'fill'=>"#FC0",'fill'=>"#FC0",'fill'=>"#CCC",'fill'=>"#09F",'fill'=>"#09F",'fill'=>"#09F",'fill'=>"#09F",'fill'=>"#09F",'fill'=>"#09F",'fill'=>"#09F",'fill'=>"#CC9",'fill'=>"#999",'fill'=>"#999",'fill'=>"#999",'fill'=>"#CC9",'fill'=>"#99C",'fill'=>"#99C",'fill'=>"#99C",'fill'=>"#99C",'fill'=>"#9C6",'fill'=>"#9C6");
$writer->writeSheetRow('routes', $rowdata, $rowstyle);
foreach($data as $datarow){
$writer->writeSheetRow('routes',$datarow);
}
return $writer->writeToString();
}
填充和這裏的電子郵件功能:
function emailL($filename1,$subject,$file1){
$multipartSep = '-----'.md5(time()).'-----';
$attch1 = chunk_split(base64_encode($file1));
$instruction ="report for today. ";
$headers = array(
"From: [email protected]",
"Reply-To: [email protected]",
"CC: [email protected]",
"Content-Type: multipart/mixed; boundary=\"$multipartSep\""
);
$body = "--$multipartSep\r\n"
. "Content-Type: text/html; charset=ISO-8859-1; format=flowed\r\n"
. "Content-Transfer-Encoding: 7bit\r\n"
. "\r\n"
. "$instruction\r\n"
. "--$multipartSep\r\n"
. "Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n"
. "Content-Transfer-Encoding: base64\r\n"
. "Content-Disposition: attachment; filename=" . $filename1 . ".xlsx\r\n"
. "\r\n"
. "$attch1\r\n"
. "--$multipartSep--";
mail("[email protected]", $subject , $body, implode("\r\n", $headers));
}
和這裏的電話:
emailL($filenameL,$filenameL,create_xl_string($totalarrayL));
我需要爲樣式使用不同的格式?問題可能是內容類型?另一方面,我找不到它在文檔中特別提到它,但是有沒有預先設置列寬的方法