Jump to content

Search the Community

Showing results for tags 'php phpexcel'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I have this test script that is acting just like my production script except production script pulls from a SQL db. I want to set the cell placement using a variable based off the count of an array. In the script below, (which you can copy and run as an example) I want to set the cell number based off how many of the same car that is in an array. So for an example there are 7 BMW's listed in the array. So I want the Comments: data copied to cell A12 using the code $num=$no+5; $cell='A'.$num; The problem I am having is it does place it on that line but it also places it 7 more times about it. If there are 4 cars of that type it would place it on the right line but also place it 3 times above it. I just want it to place it once at the desired location. Any help would be great. Here is the code: <?PHP require_once 'Classes/PHPExcel.php'; include 'Classes/PHPExcel/Writer/Excel2007.php'; $dataArray= array(); $cars=array("Versa","Volt","Volt","Volt","Volt","Volkswagen","Bentley","Benz","BMW","BMW","BMW","BMW","BMW","BMW","BMW","Cobra","Cord","Daewoo","Datsun","Dodge","Dodge","Dixi"); $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0); while (list($var, $val) = each($cars)) { if ($val!=$id){ $dataArray = array(); $objWorksheet = new PHPExcel_Worksheet($objPHPExcel); $objPHPExcel->addSheet($objWorksheet); $objWorksheet->setTitle(''. $val); $row_array[$val] = $val; array_push($dataArray,$row_array); $no = count($dataArray); $num=$no+5; $cell='A'.$num; $objWorksheet->setCellValue('A1' , $no); $objWorksheet->setCellValue('A2' , $val); $objWorksheet->setCellValue($cell , 'Comments:'); $id = $val; } else { $row_array[$val] = $val; $count=count($cars); $count2=count($loc); array_push($dataArray,$row_array); $no = count($dataArray); $num=$no+5; $cell='A'.$num; $objWorksheet->setCellValue('A2' , $no); $objWorksheet->setCellValue('A3' , $val); $objWorksheet->setCellValue($cell , 'Comments:'); $id = $val; } } // Save Excel 2007 file #echo date('H:i:s') . " Write to Excel2007 format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); ob_end_clean(); // We'll be outputting an excel file header('Content-type: application/vnd.ms-excel'); // It will be called file.xls header('Content-Disposition: attachment; filename="cars.xlsx"'); $objWriter->save('php://output'); Exit; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.