123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- <?php
- class Model_Excel extends Lin_Model {
- function __construct(){
- parent::__construct();
- }
- public function get_fz($info_list,$titlename,$filename,$tail,$ts=0)
- {
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= $titlename;
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($info_list as $key=>$value)
- {
- if($value['fpdata'] == '')
- {
- continue;
- }
- $str .= "<tr>";
- foreach ($value as $ke=>$va)
- {
- if($ke == 'shipremarks')
- {
- $va = str_replace(array('<','>'),array('<','>'),$va);
- }
- if($ke == 'orderinfo' || $ke == 'waybill')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$va."</td>";
- }
- else if($ke != 'fpdata' && $ke != 'hl' && $ke != 'currencytitle')
- {
- $str .= "<td align='left'>".$va."</td>";
- }
- }
- $str .= "<td><table border=1>";
- $a = 0;
- foreach ($value['fpdata'] as $k=>$v)
- {
- $vd = '';
- foreach ($v as $vv)
- {
- $vd .= "<td>".$vv."</td>";
- }
- $str .= "<tr>".$vd."</tr>";
- $endv = is_numeric(end($v))?end($v):0;
- $a = $a + $endv;
- }
- $str .= "</table></td>";
- if($ts != 1)
- {
- $str .= "<td>".$a."</td>";
- }
- $str .= "</tr>\n";
- }
- $str .= $tail;
- $str .= "</table></body></html>";
- 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" );
- exit($str);
- //return $str;
- }
- public function get_fz2($info_list,$titlename,$filename,$tail)
- {
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= $titlename;
- $str .= "<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 = '';
- /**
- if($ke == 'phone' || $ke == 'waybill')
- {
- $tj = ' ';
- }
- if($ke == 'orderinfo' || $ke == 'zipcode'|| $ke == 'paypal'|| $ke == 'rpaypal')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$va."</td>";//使用文本格式
- }
- else if($ke != 'fpdata' && $ke != 'hl' && $ke != 'currencytitle')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$tj.trim($va,' ')."</td>"; //.$tj.$va.
- }
- **/
- //文本: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' style='vnd.ms-excel.numberformat:@'>".trim($va,' ')."\t"."</td>"; //.$tj.$va.
- }
- }
- $str .= "</tr>\n";
- }
- $str .= $tail;
- $str .= "</table></body></html>";
- 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" );
- exit($str);
- //return $str;
- }
-
- public function get_fz2_bc($info_list,$titlename,$filename,$tail)
- {
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= $titlename;
- $str .= "<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 = '';
- /**
- if($ke == 'phone' || $ke == 'waybill')
- {
- $tj = ' ';
- }
- if($ke == 'orderinfo' || $ke == 'zipcode'|| $ke == 'paypal'|| $ke == 'rpaypal')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$va."</td>";//使用文本格式
- }
- else if($ke != 'fpdata' && $ke != 'hl' && $ke != 'currencytitle')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$tj.trim($va,' ')."</td>"; //.$tj.$va.
- }
- **/
- //文本: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')
- {
- if(is_string($va))
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".trim($va,' ')."\t"."</td>"; //.$tj.$va.
- }
- }
- }
- $str .= "</tr>\n";
- }
- $str .= $tail;
- $str .= "</table></body></html>";
- return $str;
- }
-
- public function get_fz3($info_list,$titlename,$filename,$tail)
- {
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= $titlename;
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($info_list as $key=>$value)
- {
- $str .= "<tr>";
- foreach ($value as $k=>$v)
- {
- if($k == 'shipremarks')
- {
- $v = str_replace(array('<','>'),array('<','>'),$v);
- }
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$v."</td>";
- }
- $str .= "</tr>\n";
- }
- $str .= $tail;
- $str .= "</table></body></html>";
- return $str;
- //return $str;
- }
-
- public function get_fz5($info_list,$titlename,$filename,$tail,$kong)//带空项
- {
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= $titlename;
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($info_list as $key=>$value)
- {
- $str .= "<tr>";$i=0;
- foreach ($kong as $k=>$a)
- {
- array_splice($value,$k,0,'');
- }
- foreach ($value as $ke=>$va)
- {
- $tj = '';
- /**
- if($ke == 'phone' || $ke == 'waybill')
- {
- $tj = ' ';
- }
- if($ke == 'orderinfo' || $ke == 'zipcode'|| $ke == 'paypal'|| $ke == 'rpaypal')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$va."</td>";//使用文本格式
- }
- else if($ke != 'fpdata' && $ke != 'hl' && $ke != 'currencytitle')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".$tj.trim($va,' ')."</td>"; //.$tj.$va.
- }
- **/
- //文本: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')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:0'>".$va."</td>";
- }
- else if($ke == 'zsbjz' || $ke == 'dtsbjz' || $ke == 'insurance')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:#,##0.00'>".$va."</td>";
- }
- else if($ke == 'zjs' || $ke == 'ts')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:#,##'>".$va."</td>";
- }
- else if($ke == 'zzl' || $ke == 'jweight' || $ke == 'weight')
- {
- if($ke == 'weight')
- {
- $va = trim($va,'kg');
- }
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:#,##0.00'>".$va."</td>";
- }
- else if($ke != 'hl' && $ke != 'currencytitle' || $ke == 'orderinfo')
- {
- $str .= "<td align='left' style='vnd.ms-excel.numberformat:@'>".trim($va,' ')."\t"."</td>";
- }
- $i++;
- }
- $str .= "</tr>\n";
- }
- $str .= $tail;
- $str .= "</table></body></html>";
- 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" );
- exit($str);
- //return $str;
- }
-
- public function get_fz6($info_list,$titlename,$filename)
- {
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= $titlename;
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
- foreach ($info_list as $key=>$value)
- {
- $str .= "<td><table border=0>";
- foreach ($value as $ke=>$va)
- {
- if($ke == 'shipremarks')
- {
- $va = str_replace(array('<','>'),array('<','>'),$va);
- }
- $str .= "<tr><td>".$va[0]."</td><td style='vnd.ms-excel.numberformat:@'>".$va[1]."</td></tr>";
- }
- $str .= "</table></td>\n";
- }
- $str .= "</tr></table></body></html>";
- 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" );
- exit($str);
- //return $str;
- }
- } //end class
|