The colors of phpexcel export excel do not match the colors in the web page

  • 2020-05-27 04:35:10
  • OfStack

Some questions about phpexcel exported color 1, how can the color of excel exported with phpexcel be different from the color display in the web page? Want to know what's going on? How to solve it? The PHP code details are as follows:
PHP code:
require_once './PHPExcel.php'; 
require_once './Excel5.php'; 
require_once './get_excel_row.php'; 
require "../include/base.php"; 
require "../include/function/006/creatExcelDb.php"; 
// check   To deal with   data ===+++++++++++++++++++++++++++++++++++++++++++++ 
$q = $db->query("select * from oa_event_sales"); 
while($a = $db->fetch_array($q)){ 
$list[] = $a; 
$ce = new creatExcelDb(); 
$re = $ce->_run($list,'served_time','client_status','oid'); 
foreach($re as $k=>$v){ 
$jq = array(); 
$title1 = client_status; 
$title2 = fin_confirm; 
$title3 = oid; 
// Remove the same value from the array  
foreach($re as $key => $val){ 
foreach($val as $key2 => $val2){ 
$jq[] = $key2; 
foreach($re as $k=>$v){ 
foreach($v as $k2=>$v2){ 
//  create 1 Handle object instances  
$objExcel = new PHPExcel(); 
//  Create a file format to write to the object instance , uncomment 
$objWriter = new PHPExcel_Writer_Excel5($objExcel); 
// Sets the document's basic properties /** Seems to be 1 Not normally **/ 
$objProps = $objExcel->getProperties(); 
$objProps->setCreator(" Yang this wooden "); 
$objProps->setLastModifiedBy(" Yang this wooden "); 
$objProps->setTitle(" Yang this wooden "); 
$objProps->setSubject(" Yang this wooden "); 
$objProps->setDescription(" Yang this wooden "); 
$objProps->setKeywords(" Yang this wooden "); 
$objProps->setCategory(" Yang this wooden "); 
// Set the current sheet Index for subsequent content operations.  
//1 General only in the use of multiple sheet Is required to display the call.  
// By default, PHPExcel It will automatically create a number 1 a sheet Is set SheetIndex=0 
$objActSheet = $objExcel->getActiveSheet(); 
// Set current activity sheet The name of the  
$objActSheet->setTitle(' The current sheetname'); 
// Set the width, the value and EXCEL I don't know what the units are, a little less than EXCEL The width of the  
//$objActSheet->getRowDimension(1)->setRowHeight(30); // highly  
// Sets the value of the cell  
$objActSheet->setCellValue('A1', ' General heading display '); 
// Set the style  
$objStyleA1 = $objActSheet->getStyle('A1'); 
$objFontA1 = $objStyleA1->getFont(); 
$objFontA1->setName(' Song typeface '); 
// Set the alignment in the center  
$objActSheet->setCellValue('A1', ' The line label \ The column tag '); 
foreach($jq as $k=>$v){ 
$objActSheet->setCellValue(get_excel_row($benmu).'1', $v); 
$objActSheet->setCellValue(get_excel_row($benmu).'1', ' A total of '); 
// Set the width  
// The width of the  
// color  
foreach($re as $k1=>$v1){ //$k1 All in A2 . behind ,k1 Is the telephone number, v1 for person- "Digital  
$objActSheet->setCellValue('A'.$y, $k1); 
// color  
foreach($jq as $k2=>$v2){ //k2 is 0 . v2 is person 
foreach($v1 as $k3=>$v3){ //$k3 for person,$v3 Is to value  
$objActSheet->setCellValue(get_excel_row("1"+count($jq)).$y, $num[$k1]); 
$objActSheet->setCellValue("A".$y," A total of "); 
// color  
foreach($jq as $k=>$v){ //k for person 
// color  
// color  
// output  
$outputFileName =time().".xls"; 
header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); 

In the above code, the color in define does not show the correct color in the exported excel? What's the reason? Why is that?
Start by defining 1 red to see what is displayed, as follows: define(" COLOR1 ", "#FF0000");
But it turns out that the definition of blue in excel is something like purple, which is not what the page looks like anyway, so confusing...
Look at this code: $objActSheet- > getStyle (' A '. $y) - > getFill()- > getStartColor()- > setARGB(COLOR1);
I don't know whether it is ok to add two 00 in front of the color. Try the effect first, and the format may be like argb(128,255,0,0). You can rule out this problem first, because a is transparent.

Related articles: