Browse Source

modify export to doc styles

pscj 9 years ago
parent
commit
4b592fe52d
1 changed files with 15 additions and 0 deletions
  1. 15 0
      Application/Common/Common/function.php

+ 15 - 0
Application/Common/Common/function.php

@@ -73,6 +73,18 @@ function output_word($data,$fileName=''){
         xmlns="http://www.w3.org/TR/REC-html40">
         <head><meta http-equiv=Content-Type content="text/html;  
         charset=utf-8">
+		<style type="text/css">
+			table  
+			{  
+				border-collapse: collapse;
+				border: none;  
+				width: 100%;  
+			}  
+			td  
+			{  
+				border: solid #CCC 1px;  
+			}  
+		</style>
         <meta name=ProgId content=Word.Document>
         <meta name=Generator content="Microsoft Word 11">
         <meta name=Originator content="Microsoft Word 11">
@@ -80,6 +92,9 @@ function output_word($data,$fileName=''){
         <body>'.$data.'</body></html>';
     
     $filepath = tmpfile();
+	$data = str_replace("<thead>\n<tr>","<thead><tr style='background-color: rgb(0, 136, 204); color: rgb(255, 255, 255);'>",$data);
+	$data = str_replace("<pre><code>","<table width='100%' style='background:silver;mso-highlight:silver'><pre><code>",$data);
+	$data = str_replace("</code></pre>","</code></pre></table>",$data);
     $len = strlen($data);
     fwrite($filepath, $data);
     header("Content-type: application/octet-stream");