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

2 Years
Discussion Span
Last Post by broj1

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:

/** Error reporting */
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

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

// Set active sheet index to the first sheet, so Excel opens this as the first sheet

// 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->save(str_replace('.php', '.xlsx', __FILE__));

// Echo done
echo date('H:i:s') , " Done writing files" , EOL;

Edited by broj1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.