RichText

Topics: Developer Forum, User Forum
Mar 27, 2009 at 12:42 PM
Edited Mar 27, 2009 at 12:42 PM
Well, there is an example on how to use RichText:
(from dev documentation)


$objRichText = new PHPExcel_RichText( $objPHPExcel->getActiveSheet()->getCell('A18') );

$objRichText->createText('This invoice is ');

<o:p> </o:p>

$objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');

$objPayable->getFont()->setBold(true);

$objPayable->getFont()->setItalic(true);

$objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );

<o:p> </o:p>

$objRichText->createText(', unless specified otherwise on the invoice.');


as i see, $objRichText corresponds to A18 cell.

first of all, i'd like to create $objRichText object, then fill it with content and styles. and after all set the cell it should be corresponded with.
is there any ways to set it independent from creating object?
Developer
Mar 30, 2009 at 5:36 AM
You can create an "orphan" PHPExcel_RichText and then later assign it to a cell:

$objRichText = new PHPExcel_RichText();
$objRichText->createText('This invoice is ');
$objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');
$objPayable->getFont()->setBold(true);
$objPayable->getFont()->setItalic(true);
$objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );
$objRichText->createText(', unless specified otherwise on the invoice.');

$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);

However, watch out if you assign the same Rich-Text object to several cells. This could give some confusion in your script.

Mar 30, 2009 at 8:25 AM
Edited Mar 30, 2009 at 8:26 AM
it works, thanks!

btw,
$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);
$objPHPExcel->getActiveSheet()->getCell('B19')->setValue($objRichText);
$objPHPExcel->getActiveSheet()->getCell('C20')->setValue($objRichText);
$objPHPExcel->getActiveSheet()->getCell('D21')->setValue($objRichText);

make $objRichText seems like it shoud be.

what kind of confusion do you mean?
Developer
Mar 30, 2009 at 1:44 PM
>> what kind of confusion do you mean?

What I had in mind was just that sharing $objRichText between cells this way is not really documented. It might be safer to do like this, so each cell has its own Rich-Text object.

$objPHPExcel->getActiveSheet()->getCell('A18')->setValue(clone $objRichText);
$objPHPExcel->getActiveSheet()->getCell('B19')->setValue(clone $objRichText);
$objPHPExcel->getActiveSheet()->getCell('C20')->setValue(clone $objRichText);
$objPHPExcel->getActiveSheet()->getCell('D21')->setValue(clone $objRichText);


But if the other thing works, I would not worry too much about this.
Mar 30, 2009 at 1:59 PM
I understand the difference.

OK, if something goes wrong - I'll tell, but some tests resulted without errors.

Thanks any way.
Sep 22, 2009 at 10:11 PM

Is there a reason that I am unable to create $objRichText = new PHPExcel_RichText( $objPHPExcel->getActiveSheet()->getCell('A18') ); twice on the same page for different cells on different sheets?

Developer
Sep 22, 2009 at 10:32 PM

@gknight:

Can you post a complete example?

Sep 22, 2009 at 10:38 PM

I am presently trying to get the "orphan" plan to work for me, but it is putting the first value over and over instead of overwriting each time in the loop

Sep 22, 2009 at 10:41 PM

oops, forgot the code.....................

<?php
session_start();
require_once('../../Connections/bgo.php');
mysql_select_db($database_bgo, $bgo);
$sub_total = 0;
$discounts = 0;
$points = 0;
$shipping = 0;
$taxes = 0;
$total = 0;

$accent = array("À", "à", "Á", "á", "Ä", "ä", "Â", "â", "Ç", "ç", "È", "è", "É", "é", "Ë", "ë", "Ê", "ê", "Ï", "ï", "Î", "î", "Ô", "ô", "Ù", "ù", "Ü", "ü", "Û", "û");
$character = array("&Agrave;", "&agrave;", "&Aacute;", "&aacute;", "&Auml;", "&auml;", "&Acirc;", "&acirc;", "&Ccedil;", "&ccedil;", "&Egrave;", "&egrave;", "&Eacute;", "&eacute;", "&Euml;", "&euml;", "&Ecirc;", "&ecirc;", "&Iuml;", "&iuml;", "&Icirc;", "&icirc;", "&Ocirc;", "&ocirc;", "&Ugrave;", "&ugrave;", "&Uuml;", "&uuml;", "&Ucirc;", "&ucirc;");

if(isset($_REQUEST['length']) && $_REQUEST['length'] != "")
{
 switch($_REQUEST['length']) {
  case "1":
   $orderDateSql = "SELECT * FROM order_totals WHERE date >= '".$_REQUEST['sdate']."' AND date <= '".$_REQUEST['edate']."' ORDER BY date, orderid";
   break;
  case "2";
   $orderDateSql = "SELECT * FROM order_totals WHERE date >= '".$_REQUEST['past']."-01-01' AND date <= '".$_REQUEST['past']."-12-31' ORDER BY date, orderid";
   break;
  case "3";
   $orderDateSql = "SELECT * FROM order_totals WHERE date >= '".date("Y")."-01-01' AND date <= '".date("Y-m-d")."' ORDER BY date, orderid";
   break;
  case "4":
   $orderDateSql = "SELECT * FROM order_totals ORDER BY date, orderid";
   break;
 }
 require_once "../Classes/PHPExcel.php";
 require_once "../Classes/PHPExcel/RichText.php";
 
 $dateTime = date("Y-m-d H:i:s");
 $objPHPExcel = new PHPExcel();
 $objPHPExcel->getProperties()->setCreator("BuyGreenOnline")
         ->setLastModifiedBy("BuyGReenOnline")
         ->setTitle("Sales report generated ".$dateTime)
         ->setSubject("Sales report generated ".$dateTime)
         ->setDescription("Sales report generated ".$dateTime)
         ->setKeywords("Sales report generated ".$dateTime)
         ->setCategory("Sales report generated ".$dateTime);
 $i=0;
 $orderDateQuery = mysql_query($orderDateSql) or die($orderDateSql."<br><br>".mysql_error());
 $orderDateNumRows = mysql_num_rows($orderDateQuery);
 
 if($orderDateNumRows > 0)
 {
  $objRichText = new PHPExcel_RichText();
  while($row_orderDate = mysql_fetch_assoc($orderDateQuery))
  {
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('A'.$i, 'Order Number');
   $objPHPExcel->getActiveSheet()->setCellValue('B'.$i, $row_orderDate['orderid']);
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Date');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $row_orderDate['date']);
   $objPHPExcel->getActiveSheet()->getStyle('A'.$i.':F'.$i)->applyFromArray(
     array(
      'font'    => array(
       'bold'      => true
      ),
      'borders' => array(
       'top'     => array(
         'style' => PHPExcel_Style_Border::BORDER_THIN
        ),
       'bottom'     => array(
         'style' => PHPExcel_Style_Border::BORDER_THIN
        )
      ),
      'fill' => array(
        'type'       => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
         'rotation'   => 90,
        'startcolor' => array(
         'argb' => 'FFA0A0A0'
        ),
        'endcolor'   => array(
         'argb' => 'FFFFFFFF'
        )
       )
     )
   );
  
   $objPHPExcel->getActiveSheet()->getStyle('A'.$i)->applyFromArray(
     array(
      'alignment' => array(
       'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
      ),
      'borders' => array(
       'left'     => array(
         'style' => PHPExcel_Style_Border::BORDER_THIN
        )
      )
     )
   );
  
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i)->applyFromArray(
     array(
      'alignment' => array(
       'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
      )
     )
   );

   $objPHPExcel->getActiveSheet()->getStyle('F'.$i)->applyFromArray(
     array(
      'borders' => array(
       'right'     => array(
         'style' => PHPExcel_Style_Border::BORDER_THIN
        )
      )
     )
   );
   $i++;
   $orderDetailSql = "SELECT * FROM order_details WHERE orderid=".$row_orderDate['orderid'];
   $orderDetailQuery = mysql_query($orderDetailSql) or die($orderDetailSql."<br><br>".mysql_error());
   while($row_orderDetail = mysql_fetch_assoc($orderDetailQuery))
   {
    $objRichText->createText($row_orderDetail['sku']);
    $objPHPExcel->getActiveSheet()->getCell('A'.$i)->setValue($objRichText);
    $objPHPExcel->getActiveSheet()->setCellValue('B'.$i, utf8_encode(str_replace($character, $accent, $row_orderDetail['name'])));
    $objPHPExcel->getActiveSheet()->setCellValue('C'.$i, utf8_encode(str_replace($character, $accent, $row_orderDetail['orderoption'])));
    $objPHPExcel->getActiveSheet()->setCellValue('D'.$i, $row_orderDetail['qty']);
    $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, $row_orderDetail['price']);
    $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, '=D'.$i.'*E'.$i);
    $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
  
    $objPHPExcel->getActiveSheet()->getStyle('A'.$i.':E'.$i)->applyFromArray(
      array(
       'alignment' => array(
        'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
       )
      )
    );
   }
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Sub-Total');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $row_orderDate['subtotal']);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->applyFromArray(array('font'=>array('bold'=>true)));
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Coupon('.$row_orderDate['coupon'].')');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, '-'.$row_orderDate['discount']);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->applyFromArray(array('font'=>array('bold'=>true)));
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Points');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, '-'.$row_orderDate['points']);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->applyFromArray(array('font'=>array('bold'=>true)));
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Shipping');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $row_orderDate['shipping']);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->applyFromArray(array('font'=>array('bold'=>true)));
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Taxes');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $row_orderDate['taxes']);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->applyFromArray(array('font'=>array('bold'=>true)));
   $i++;
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, 'Total');
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $row_orderDate['total']);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
   $objPHPExcel->getActiveSheet()->getStyle('E'.$i.':F'.$i)->applyFromArray(array('font'=>array('bold'=>true)));
   $i++;
  }
  
  $objPHPExcel->getActiveSheet()->setTitle('Order List');
  $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
  $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
  $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
  $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(8);
  $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
  $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(12);
  
  $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
  $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
  
  //SHEET 2
  $objPHPExcel->createSheet();
  $objPHPExcel->setActiveSheetIndex(1);
  $j=1;
  
  $objPHPExcel->getActiveSheet()->setCellValue('A'.$j, 'Date');
  $objPHPExcel->getActiveSheet()->setCellValue('B'.$j, 'Order');
  $objPHPExcel->getActiveSheet()->setCellValue('C'.$j, 'Coupon Code');
  $objPHPExcel->getActiveSheet()->setCellValue('D'.$j, 'Discount');
  $objPHPExcel->getActiveSheet()->setCellValue('E'.$j, 'Points');
  $objPHPExcel->getActiveSheet()->setCellValue('F'.$j, 'Sub-Total');
  $objPHPExcel->getActiveSheet()->setCellValue('G'.$j, 'Shipping');
  $objPHPExcel->getActiveSheet()->setCellValue('H'.$j, 'Taxes');
  $objPHPExcel->getActiveSheet()->setCellValue('I'.$j, 'Total');

  $objPHPExcel->getActiveSheet()->getStyle('A'.$j.':I'.$j)->applyFromArray(
    array(
     'font'    => array(
      'bold'      => true
     ),
     'borders' => array(
      'top'     => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
       ),
      'bottom'     => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
       )
     ),
     'fill' => array(
       'type'       => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
        'rotation'   => 90,
       'startcolor' => array(
        'argb' => 'FFA0A0A0'
       ),
       'endcolor'   => array(
        'argb' => 'FFFFFFFF'
       )
      )
    )
  );

  $objPHPExcel->getActiveSheet()->getStyle('I'.$i)->applyFromArray(
    array(
     'borders' => array(
      'right'     => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
       )
     )
    )
  );

  $j++;
  $skuSql = "SELECT * FROM order_totals ORDER BY orderid";
  $skuQuery = mysql_query($skuSql) or die($skuSql."<br><br>".mysql_error());
  while($row_sku = mysql_fetch_assoc($skuQuery))
  {
   $objPHPExcel->getActiveSheet()->setCellValue('A'.$j, $row_sku['date']);
   $objPHPExcel->getActiveSheet()->setCellValue('B'.$j, $row_sku['orderid']);
   $objPHPExcel->getActiveSheet()->setCellValue('C'.$j, $row_sku['coupon']);
   $objPHPExcel->getActiveSheet()->setCellValue('D'.$j, $row_sku['discount']);
   $objPHPExcel->getActiveSheet()->getStyle('D'.$j)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$j, $row_sku['points']);
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$j, $row_sku['subtotal']);
   $objPHPExcel->getActiveSheet()->getStyle('F'.$j)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
   $objPHPExcel->getActiveSheet()->setCellValue('G'.$j, $row_sku['shipping']);
   $objPHPExcel->getActiveSheet()->getStyle('G'.$j)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
   $objPHPExcel->getActiveSheet()->setCellValue('H'.$j, $row_sku['taxes']);
   $objPHPExcel->getActiveSheet()->getStyle('H'.$j)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
   $objPHPExcel->getActiveSheet()->setCellValue('I'.$j, $row_sku['total']);
   $objPHPExcel->getActiveSheet()->getStyle('I'.$j)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
   $j++;
  }
  $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
  $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(8);
  $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
  $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10);
  $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(8);
  $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(10);
  $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(10);
  $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(10);
  $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(10);

  $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
  $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
  $objPHPExcel->getActiveSheet()->setTitle('Order Details');
  
  //SHEET 3
  $objPHPExcel->createSheet();
  $objPHPExcel->setActiveSheetIndex(2);
  $k=1;
  
  $objPHPExcel->getActiveSheet()->setCellValue('A'.$k, 'Bar Code');
  $objPHPExcel->getActiveSheet()->setCellValue('B'.$k, 'Order');
  $objPHPExcel->getActiveSheet()->setCellValue('C'.$k, 'Product');
  $objPHPExcel->getActiveSheet()->setCellValue('D'.$k, 'Option');
  $objPHPExcel->getActiveSheet()->setCellValue('E'.$k, 'Qty');
  $objPHPExcel->getActiveSheet()->setCellValue('F'.$k, 'Price');
  $objPHPExcel->getActiveSheet()->getStyle('A'.$k.':F'.$k)->applyFromArray(
    array(
     'font'    => array(
      'bold'      => true
     ),
     'borders' => array(
      'top'     => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
       ),
      'bottom'     => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
       )
     ),
     'fill' => array(
       'type'       => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
        'rotation'   => 90,
       'startcolor' => array(
        'argb' => 'FFA0A0A0'
       ),
       'endcolor'   => array(
        'argb' => 'FFFFFFFF'
       )
      )
    )
  );

  $objPHPExcel->getActiveSheet()->getStyle('F'.$i)->applyFromArray(
    array(
     'borders' => array(
      'right'     => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
       )
     )
    )
  );
  
  $k++;
  $detailsSql = "SELECT * FROM order_details ORDER BY sku, orderid";
  $detailsQuery = mysql_query($detailsSql) or die($detailsSql."<br><br>".mysql_error());
  while($row_details = mysql_fetch_assoc($detailsQuery))
  {
   $objRichText->createText($row_details['sku']);
   $objPHPExcel->getActiveSheet()->getCell('A'.$k)->setValue($objRichText);
   //$objPHPExcel->getActiveSheet()->setCellValue('A'.$k, $row_details['sku']);
   $objPHPExcel->getActiveSheet()->setCellValue('B'.$k, $row_details['orderid']);
   $objPHPExcel->getActiveSheet()->setCellValue('C'.$k, utf8_encode(str_replace($character, $accent, $row_details['name'])));
   $objPHPExcel->getActiveSheet()->setCellValue('D'.$k, utf8_encode(str_replace($character, $accent, $row_details['orderoption'])));
   $objPHPExcel->getActiveSheet()->setCellValue('E'.$k, $row_details['qty']);
   $objPHPExcel->getActiveSheet()->setCellValue('F'.$k, $row_details['price']);
   $objPHPExcel->getActiveSheet()->getStyle('F'.$k)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
   $k++;
  }
  
  $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(18);
  $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(8);
  $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
  $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
  $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(8);
  $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(10);

  $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
  $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
  $objPHPExcel->getActiveSheet()->setTitle('Product Details');

  require_once('../Classes/PHPExcel/IOFactory.php');
  
  $objPHPExcel->setActiveSheetIndex(0);
  $filename = date("Y-m-d").'_Sales_Report';
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel2007');
  $objWriter->save($filename.".xlsx");
  
  $zipname = $filename.".zip";
  $zip = new ZipArchive();
  
  if ($zip->open($zipname, ZIPARCHIVE::CREATE)!==TRUE) {
      exit("cannot open <$zipname>\n");
  }
  $zip->addFile($filename.".xlsx");
  $zip->close();
  unlink($filename.".xlsx");
  header("location: ".$zipname);

 }
 else
 {
  //header("location: reports.php");
  echo "No data";
 }
}
else
{
 //header("location: reports.php");
 echo "No request";
}
?>

Developer
Sep 22, 2009 at 11:01 PM

Essentially you have this:

$objRichText = new PHPExcel_RichText();
while($row_orderDetail = mysql_fetch_assoc($orderDetailQuery))
{
$objRichText->createText($row_orderDetail['sku']);
$objPHPExcel->getActiveSheet()->getCell('A'.$i)->setValue($objRichText);
...
}


Can you try this instead and report back if it solves the problem?

while($row_orderDetail = mysql_fetch_assoc($orderDetailQuery))
{
$objRichText = new PHPExcel_RichText();
$objRichText->createText($row_orderDetail['sku']);
   $objPHPExcel->getActiveSheet()->getCell('A'.$i)->setValue($objRichText);
    ...
}

 

Sep 22, 2009 at 11:23 PM

It worked perfectly. Thank you so very much. That was actually the END of that contract......................lol