Hy i'm using php excell to export some data from my db, one of the collum have full path of a image, instead of show me the path it is possible to make a link? like <a href="row[photo]">Link</a> ? i've tryied to search but nothing...i'm using the lasted phpexcell class

Recommended Answers

All 3 Replies

You might want to try the HYPERLINK() formula. Haven't tested this, just looked up some info on the net. See also this link.

nothing helps me...;(

Sory to come back so late, was quite busy. The approach actually works for me. This is a script, adapted from the example 3 of the PHPExcel examples:

<?php
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

/** Include PHPExcel */
// Use correct path here
$excelClass = '../../PHPExcel/Classes/PHPExcel.php';
require_once $excelClass;

$objPHPExcel = new PHPExcel();

// Set document properties
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
                             ->setLastModifiedBy("Maarten Balliauw")
                             ->setTitle("Office 2007 XLSX Test Document")
                             ->setSubject("Office 2007 XLSX Test Document")
                             ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
                             ->setKeywords("office 2007 openxml php")
                             ->setCategory("Test result file");

// set textual link and hyperlink by a formula
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'TEXT')
                              ->setCellValue('A2', 'LINK')
                              ->setCellValue('B1', "http://www.daniweb.com")
                              ->setCellValue('B2', '=HYPERLINK("http://www.daniweb.com")');

// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('Formulas');


// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);

// Save Excel 2007 file
$callStartTime = microtime(true);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

//
//  If we set Pre Calculated Formulas to true then PHPExcel will calculate all formulae in the
//    workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
//    using functions or features (such as array formulae) that aren't yet supported by the calculation engine
//  If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to
//    open the file) will need to recalculate values itself to guarantee that the correct results are available.
//
//$objWriter->setPreCalculateFormulas(true);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

// Echo done
echo date('H:i:s') , " Done writing files" , EOL;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.