phpexcel


Getting cells by coordinate

醉酒当歌 提交于 2020-02-21 13:44:30
问题 foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); // I wish echo $cellIterator->getCell("A3"); // row: $row, cell: A3 } } I'm looking for a similar method which named getCell above or well-writed PHPExcel documentation. Thanks. 回答1: If you have the $row information from RowIterator, you can just easily call: $rowIndex = $row->getRowIndex ();

Getting cells by coordinate

自古美人都是妖i 提交于 2020-02-21 13:43:46
问题 foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); // I wish echo $cellIterator->getCell("A3"); // row: $row, cell: A3 } } I'm looking for a similar method which named getCell above or well-writed PHPExcel documentation. Thanks. 回答1: If you have the $row information from RowIterator, you can just easily call: $rowIndex = $row->getRowIndex ();

Extracting pictures/images within an Excel file (xls) using PHP

房东的猫 提交于 2020-02-21 12:33:23
问题 I have a spreadsheet that I would like to import using PHP. I can import the cell data using PHPExcel, but can't figure out how to use images from within the spreadsheet. Is there a way of doing this and then using the images within PHP to save to the server etc? Many thanks for the help! :) Update: @mark-baker - thank you so much for your help with this! I have used the code below on a test XLS file with one JPG: $objPHPExcel = PHPExcel_IOFactory::load("SH.xls"); foreach ($objPHPExcel-

Extracting pictures/images within an Excel file (xls) using PHP

只愿长相守 提交于 2020-02-21 12:32:21
问题 I have a spreadsheet that I would like to import using PHP. I can import the cell data using PHPExcel, but can't figure out how to use images from within the spreadsheet. Is there a way of doing this and then using the images within PHP to save to the server etc? Many thanks for the help! :) Update: @mark-baker - thank you so much for your help with this! I have used the code below on a test XLS file with one JPG: $objPHPExcel = PHPExcel_IOFactory::load("SH.xls"); foreach ($objPHPExcel-

Download with php with headers do not work on IE8

南楼画角 提交于 2020-02-01 05:37:13
问题 I am trying to download a excel file generated on the fly with php headers: $filename = "assets.xls"; header('Content-Type: application/vnd.ms-excel'); header("Content-Disposition: attachment;filename=$filename"); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); But this does not work on IE8 (but on some other pc with IE8 works???!!). IE8 tries to download the export.php file instead of assets.xls. Any

Phpspreadsheet - Time cell retrieved as float

前提是你 提交于 2020-01-30 09:50:29
问题 I have an excel file which has a time input. Mar 01, 2018 | Thursday | 8:00 AM | 5:00 PM Mar 02, 2018 | Friday | 8:00 AM | 5:00 PM But when my code tries to read those cells, the output becomes a float (for example 8:00 AM becomes 0.33333333333333 ). This is my code $date = $sheet->getCell("A".$row)->getValue(); $time_in = $sheet->getCell("C".$row)->getValue(); $time_out = $sheet->getCell("D".$row)->getValue(); echo "date: ".$date. //Mar 01, 2018 " time_in: ".$time_in. //becomes 0

phpexcel how get cell format

[亡魂溺海] 提交于 2020-01-30 08:43:11
问题 How I can get cell format? I Try $E->getActiveSheet()->getCellByColumnAndRow(0, 24)->getCalculatedValue() but it rerurns '6', I need '6 бухта' (sorry for russian letters) 回答1: $E->getActiveSheet()->getCellByColumnAndRow(0, 24) ->getFormattedValue() 回答2: you can get the cell format by code, var_dump($objPHPExcel->getActiveSheet()->getCell('D3')->getStyle()->getNumberFormat()->getFormatCode()); and output will be like: string(8) "mm-dd-yy" 来源: https://stackoverflow.com/questions/15722801

How to close excel file in php-excel-reader

大兔子大兔子 提交于 2020-01-25 10:26:07
问题 I am reading two excel file, using php-excel-reader (From this) After reading two files of 1st row, I am comparing it. If they are same then I am appending contain of on file to other. To write the file I am using this Now for doing this I want to close one file, but that function is not available in php-excel-reader here is my code compare file { $data = new Spreadsheet_Excel_Reader($filepath); $data1 = new Spreadsheet_Excel_Reader($destinationfilepath); } unset($data); unset($data1); if(

How to generate a password protected spreadsheet from PHP?

末鹿安然 提交于 2020-01-24 07:21:52
问题 How to generate a password protected spreadsheet from PHP ? I tried PHPExcel library from http://phpexcel.codeplex.com/ PHPExcel offers 3 levels of “protection”: document security, sheet security and cell security. Document security allows you to set a password on a complete spreadsheet, allowing changes to be made only when that password is entered. But user can open the spreadsheet and view the contents without password. And I tried Spreadsheet_Excel_Writer as well, but did not find any

Set cell value using PHPExcel and setCellValue method

微笑、不失礼 提交于 2020-01-17 05:33:06
问题 I'm trying to set|persist some values in a Excel (.xlsx) file and I'm using phpoffice/phpexcel library. This is how my code looks: $objReader = \PHPExcel_IOFactory::createReader('Excel2007'); $objPHPExcel = $objReader->load($filename); $objWorksheet = $objPHPExcel->getActiveSheet(); $objPHPExcel->getActiveSheet()->setCellValue('A'.$cRow, $hcpId); // set column A - HCP.ID - value $objPHPExcel->getActiveSheet()->setCellValue('B'.$cRow, $terrID); // set column B - TERRITORY.ID - value

工具导航Map