lvhao 1 週間 前
コミット
295014dc50
1 ファイル変更38 行追加12 行削除
  1. 38 12
      core/CoreApp/controllers/Color.php

+ 38 - 12
core/CoreApp/controllers/Color.php

@@ -662,7 +662,7 @@ class Color extends Start_Controller {
 				$colorimg = explode('|',$value['img']);
 				$v = $colorimg[0];
 				$img_list = [];
-				$str_img = '<table class="img_container"><tr>';
+				$str_img = '<table class="img_container" width="100%" cellspacing="0" cellpadding="0"><tr>';
 				foreach ($colorimg as $k=>$v) 
 				{
 					
@@ -688,7 +688,7 @@ class Color extends Start_Controller {
 						$dataUri = 'data:' . $mimeType . ';base64,' . $base64;
 					
 						//$info_list[$key]['img'] = "<img width='170' src='".$dataUri."'>";
-						$str_img .= "<td ><img width='170' src='".$dataUri."'></td>";
+						$str_img .= "<td width='25%' style='width:25%;'><img width='170' src='".$dataUri."'></td>";
 					}else{
 						
 					}
@@ -728,23 +728,49 @@ class Color extends Start_Controller {
 		<style>
 			tr { mso-height-source: auto; }
 			.fixed-height { 
-				height: 220px; /* 设置固定行高 */
-				mso-height-source: userset; /* 强制Excel使用设定高度 */
+				height: 220px;
+				mso-height-source: userset;
 			}
-			.img_container{
+			
+			/* Excel兼容的图片布局方案 */
+			.img_container {
 				width: 100%;
 				mso-table-lspace: 0pt;
 				mso-table-rspace: 0pt;
 				border-collapse: collapse;
-				table-layout: fixed;
+				table-layout: fixed; /* 关键:固定表格布局 */
 			}
-			.img_container td{
-				width:200px;
+			
+			.img_container td {
+				width: 25%; /* 每行最多4张图片 */
 				vertical-align: top;
 				text-align: center;
 				padding: 2px;
+				/* 添加这些以确保宽度正确 */
 				mso-cellspacing: 0pt;
-				mso-padding-alt: 0px 0px 0px 0px;
+				mso-padding-alt: 0pt 0pt 0pt 0pt;
+				overflow: hidden;
+			}
+			
+			.img_container img {
+				width: 100%; /* 图片填充单元格宽度 */
+				max-width: 170px; /* 最大宽度限制 */
+				max-height: 200px;
+				height: auto;
+				display: block;
+				margin: 0 auto;
+				/* 添加这些以增强兼容性 */
+				mso-width-percent: 1000; /* 100%的百分比表示 */
+				mso-height-relative: page;
+			}
+			
+			/* 关键:确保单元格宽度精确计算 */
+			.img_container[width] {
+				mso-width-percent: 1000;
+			}
+			.img_container td[width='25%'] {
+				width: 25% !important;
+				mso-width-percent: 250; /* 25%的百分比表示 */
 			}
 			
 			
@@ -752,9 +778,9 @@ class Color extends Start_Controller {
 		</head>
 		<body>";
 		
-		$str .= "<table border='1' cellspacing='0' style='border-collapse: collapse; font-family: Microsoft Yahei; font-size: 13px;'>"; 
+		$str .= "<table border='1' cellspacing='0' style='border-collapse: collapse; font-family: Microsoft Yahei; font-size: 13px;'><col width='150'><col width='80'><col width='100'><col width='50'><col width='50'><col width='150'><col width='80'><col width='100'><col width='120'><col width='600'> "; 
 		$str .= "<tr >"; // 应用固定高度类
-		$str .= "<td>标题</td><td>是否在售</td><td>配图类型</td><td>色号</td><td>曲度</td><td>备注</td><td>开发人</td><td>重要信息提醒</td><td>添加时间</td><td width='20%'>图片</td>";
+		$str .= "<td>标题</td><td>是否在售</td><td>配图类型</td><td>色号</td><td>曲度</td><td>备注</td><td>开发人</td><td>重要信息提醒</td><td>添加时间</td><td width='600'>图片</td>";
 		$str .= "</tr>";
 		foreach($info_list as $key => $value){
 			$str .= "<tr class='fixed-height'>"; // 应用固定高度类
@@ -767,7 +793,7 @@ class Color extends Start_Controller {
 			$str .= "<td>".$value['developer']."</td>";
 			$str .= "<td>".$value['craft_process']."</td>";
 			$str .= "<td>".$value['time']."</td>";
-			$str .= "<td>".$value['img']."</td>";
+			$str .= "<td width='600'>".$value['img']."</td>";
 			$str .= "</tr>";
 		}