This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/pc/include/excel_fun.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

180 lines
4.3 KiB
PHP

<?php
function save_tmp_file($file){
$file_name=gsession();
$xls_file_name=$file_name.".xls";
upload_file($file["tmp_name"],THIS_FILE_ROOT."/cache",$xls_file_name);
$sheet=Read_Excel_File(THIS_FILE_ROOT."/cache/".$xls_file_name,$return);
$content="";
if($return){
for($i=0;$i<count($return[$sheet['name'][0]]);$i++){
$line="";
for($j=0;$j<count($return[$sheet['name'][0]][$i]);$j++){
$line.=$return[$sheet['name'][0]][$i][$j]."|^_^|";
}
if($line){
$line=substr($line,0,-5);
$content.=str_replace("\r\n","",$line)."|-|-|";
}
}
}
if($content)
$content=substr($content,0,-1);
write_file(THIS_FILE_ROOT."/cache",$file_name,$content);
return $file_name;
}
//
function del_tmp_file($file){
del_file(THIS_FILE_ROOT."/cache/".$file);
del_file(THIS_FILE_ROOT."/cache/".$file.".xls");
}
//
function get_tmp_content($file){
$content=read_file(THIS_FILE_ROOT."/cache/".$file);
return $content;
}
//
function get_table_thead($content){
$arr=explode("|-|-|",$content);
$arr=explode("|^_^|",$arr[0]);
return $arr;
}
//
function check_table_thead($arr_head,$arr_head_global){
global $arr_column_client_pinpai;
$arr1=$arr2=array();
$arr3=$arr_column_client_pinpai;
for($i=0;$i<count($arr_head);$i++){
if(in_array($arr_head[$i],$arr_head_global)){
$arr1[]=$i;
$arr2[]=get_main_key($arr_head_global,$arr_head[$i]);
}
}
return array($arr1,$arr2);
}
//
function parse_xls($arr){
$cols=count($arr[0]);
$rows=count($arr);
$t_width=$cols*54;
$str="<html xmlns:o=\"urn:schemas-microsoft-com:office:office\"
xmlns:x=\"urn:schemas-microsoft-com:office:excel\"
xmlns=\"http://www.w3.org/TR/REC-html40\">
<head>
<meta http-equiv=Content-Type content=\"text/html; charset=gb2312\">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content=\"Microsoft Excel 11\">
<style>
<!--table
{mso-displayed-decimal-separator:\"\.\";
mso-displayed-thousand-separator:\"\,\";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;}
tr
{mso-height-source:auto;
mso-ruby-visibility:none;}
col
{mso-width-source:auto;
mso-ruby-visibility:none;}
br
{mso-data-placement:same-cell;}
.style0
{mso-number-format:General;
text-align:general;
vertical-align:middle;
white-space:nowrap;
mso-rotate:0;
mso-background-source:auto;
mso-pattern:auto;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
border:none;
mso-protection:locked visible;
mso-style-name:常规;
mso-style-id:0;}
td
{mso-style-parent:style0;
padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;
display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:Selected/>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>8640</x:WindowHeight>
<x:WindowWidth>17955</x:WindowWidth>
<x:WindowTopX>720</x:WindowTopX>
<x:WindowTopY>315</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body link=blue vlink=purple><table x:str border=0 cellpadding=0 cellspacing=0 style='border-collapse:
collapse;table-layout:fixed;width:".$t_width."pt'>
<col width=72 span=".$cols." style='width:54pt'>";
for($i=0;$i<$rows;$i++){
$str.="<tr>";
for($j=0;$j<$cols;$j++){
$str.="<td width=72 style='width:54pt' x:string>".$arr[$i][$j]."</td>";
}
$str.="</tr>";
}
$str.="
</table>
</body>
</html>";
return $str;
}
?>