| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * 采用循环输入的模式
- */
- class Model_excelxh extends Lin_Model {
- function __construct(){
- parent::__construct();
- }
- public function get_fz2($info_list, $titlename, $filename, $tail){
- //这样 echo 的内容就会直接往外发,不会再在内存里堆成大球
- while (ob_get_level()) {
- ob_end_clean();
- }
- header("Content-Type: application/vnd.ms-excel; name='excel'");
- header("Content-type: application/octet-stream");
- header("Content-Disposition: attachment; filename=" . $filename);
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Pragma: no-cache");
- header("Expires: 0");
- echo '<html xmlns:x="urn:schemas-microsoft-com:office:excel">';
- echo '<head>';
- echo '<!--[if gte mso 9]><xml>';
- echo '<x:ExcelWorkbook>';
- echo '<x:ExcelWorksheets>';
- echo '<x:ExcelWorksheet>';
- echo '<x:Name>EXCEL</x:Name>';
- echo '<x:WorksheetOptions>';
- echo '<x:Print>';
- echo '<x:ValidPrinterInfo />';
- echo '</x:Print>';
- echo '</x:WorksheetOptions>';
- echo '</x:ExcelWorksheet>';
- echo '</x:ExcelWorksheets>';
- echo '</x:ExcelWorkbook>';
- echo '</xml>';
- echo '<![endif]-->';
- echo '</head><body>';
-
- echo $titlename;
- echo "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($info_list as $key=>$value)
- {
- $str = "<tr>";
- foreach ($value as $ke=>$va)
- {
- $tj = '';
- //文本:vnd.ms-excel.numberformat:@
- //日期:vnd.ms-excel.numberformat:yyyy/mm/dd
- //数字:vnd.ms-excel.numberformat:#,##0.00
- //货币:vnd.ms-excel.numberformat:¥#,##0.00
- //百分比:vnd.ms-excel.numberformat: #0.00%
- if($ke == 'shipremarks')
- {
- $va = str_replace(array('<','>'),array('<','>'),$va);
- }
- if($ke == 'shouldmoney' || $ke == 'freight' || $ke == 'expressmoney' || $ke == 'budget' || $ke == 'cost' || $ke == 'refundy' || $ke == 'refundj')
- {
- $str .= "<td align='left'>".$va."</td>";//使用文本格式
- }
- else if($ke == 'ts' || $ke == 'zsbjz')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:0'>".$va."</td>";
- }
- else if($ke == 'zzl')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:#,##0.00'>".$va."</td>";
- }
- else if($ke != 'fpdata' && $ke != 'hl' && $ke != 'currencytitle' || $ke == 'orderinfo')
- {
- $str .= "<td align='left' x:str style='mso-number-format:".' "\@'.'" '.";vnd.ms-excel.numberformat:0'>".trim($va,' ')."\t"."</td>"; //.$tj.$va.
- }
- }
- $str .= "</tr>\n";
- echo $str;
- }
- echo $tail."</table></body></html>";
-
- exit();
- }
- }
|