Jump to content

Nell

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Nell

  1. I tried the following code, and exited before the first header - it gives me a blank page (no output). error_reporting(E_ALL); ini_set('display.errors', 1); -- Yes teynon, i'm using: $objWriter->save("phpCOLONSLASHSLASHoutput"); But you say that i have to remove it because it wipes out the line? -- I commented out the headers and the result is corrupted data printed to the web broswer: (I shortened the entire output) ÐÏࡱá;þÿ þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Àà ÀàÈàÈàÈà ÈàÈàÈàÈàÌàÌàÀàÈàÈàÈàÈàèàÈàèà¤ìà%ìà¥ìàèàèàèà¥ìà%ìà¦ÌàÈà§ìà¦Ìà§ìà§ìŠà§ìŠàè‹àè‹à Èà ÈàÈàØàÈàÈàÀàè‹àè‹àè‹àȉàÈàÈà Ø“€ÿ’â8ÿÿÿîì᥶Êÿÿ}$ }ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ -- And finally I added the : require_once 'PHPExcel/PHPExcel.php'; And i'm getting the same corrupted data as i posted above. -- This is my entire code: // processing form submitted // if (!isset($_POST['btnSubmit'])) exit; error_reporting(E_ALL); ini_set('display.errors', 1); //include PHPExcel library// require_once "Classes/PHPExcel/IOFactory.php"; require_once "Classes/PHPExcel.php"; // Load Files // $objTpl = PHPExcel_IOFactory::load("template.xlsx"); $objTpl->setActiveSheetIndex(); //set first sheet as active $objTpl2 = PHPExcel_IOFactory::load("file.xls"); // Set the Cells with values // $objTpl->getActiveSheet()->getStyle('C2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); //C1 is right-justified $objTpl->getActiveSheet()->setCellValue('F3', date('Y-m-d')); //set C1 to current date $objTpl->getActiveSheet()->getStyle('C4')->getAlignment()->setWrapText(true); //set wrapped for some long text message $objTpl->getActiveSheet()->getColumnDimension('C')->setWidth(40); //set column C width $objTpl->getActiveSheet()->getRowDimension('4')->setRowHeight(120); //set row 4 height $objTpl->getActiveSheet()->getStyle('A4:C4')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); //A4 until C4 is vertically top-aligned $objTpl->getActiveSheet()->setCellValue('D3', $objTpl2->getActiveSheet(1)->GetCell('B1')->getValue()); $objTpl->getActiveSheet()->setCellValue('B1',$objTpl2->getActiveSheet()->GetCell('B1')->getValue()); // Prepare Download // $filename='goodFile.xlsx'; //Sets the Filename header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="'.$filename.'"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objTpl, 'Excel5'); $objWriter->save("phpCOLONSLASHSLASHoutput"); exit; //done.. exiting!
  2. The program sends corrupted data to the download file. Something in my code is corrupting the sent data.
  3. Hello PhpFreaks! I'm trying to use Phpexcel to extract data from one excel sheet to be able to write it to a template excel sheet. But I can't seem to get the entire thing working. For example; taking the value of the cell "C4" in the excel Spreadsheet "Firstsheet.xls". And to write it to a new excel sheet, "Template.xls" in the cell "D2". I'm currently trying to use this: $objPHPExcel = PHPExcel_IOFactory::load("FirstSheet.xls"); $objPHPExcel2 = PHPExcel_IOFactory::load("Template.xls"); $objPHPExcel2->getActiveSheet()->setCellValue('D2',$objPHPExcel->getActiveSheet()->GetCell('C4')->getValue()); However, opening up two sources at the same time is seen as "bad coding"; a possible solution might be to either to open up the first excel sheet and store it to a multiple dimension array, close it. Then to open up the second sheet and access the data of the first sheet from the array. But I'm not really sure how to do so. -- This is my code so far, that needs fixing: Thanks, Nell
×
×
  • 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.