标签: phpexcelreader

在php中的phpexcel中将图像添加到Excel中

我是从phpexcel那里得到的例子

我只是尝试在GET方法中传递值,我完成了.

现在我想在a3 coloumn中添加图像.

参考代码 :

<?php
$value = $_GET['value'];
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');

if (PHP_SAPI == 'cli')
    die('This example should only be run from a Web Browser');

require_once dirname(__FILE__) . '/Classes/PHPExcel.php';


$objPHPExcel = new PHPExcel();


$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");


$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', $value)
            ->setCellValue('B2', 'world!')
            ->setCellValue('C1', 'Hello')
            ->setCellValue('D2', 'world!'); …
Run Code Online (Sandbox Code Playgroud)

php phpexcel phpexcelreader

23
推荐指数
3
解决办法
6万
查看次数

PHPExcel - 生成Excel报告期间的数据填充不正确

我正在研究Symfony 2.1中的一个项目.PHPExcel版本是1.8.0.我使用Doctrine从Db中检索数据并根据需要进行过滤.

    $em = $this->getDoctrine()->getManager();
    $guardquery = $em->createQueryBuilder()
            ->select('g.attendancePopupTime', 'd.atmName', 'd.region', 'd.zone', 'd.state')
            ->from('ATMMonitorAPIBundle:GuardMonitor', 'g')
            ->innerJoin('ATMMonitorAPIBundle:DeviceAtmInfo', 'd', Join::WITH, 'd.deviceId = g.deviceId');

    if ($userZones[0]['userZones'] != '0') {
        $guardquery->innerJoin('ATMMonitorAPIBundle:RegisteredDevices', 'r', Join::WITH, 'r.deviceId = g.deviceId')
                ->where('r.deviceZone IN (:devicezone)')
                ->setParameter('devicezone', $zone_array);
    }

    if (isset($dateLow)) {
        $guardquery->andWhere('g.attendancePopupTime BETWEEN :date_low and :date_high')
                ->setParameter('date_low', $dateLow)
                ->setParameter('date_high', $dateHigh);
    }

    $finalAttendanceQuery = $guardquery->getQuery();
    $attendanceResult = $finalAttendanceQuery->getArrayResult();
Run Code Online (Sandbox Code Playgroud)

这是我的查询,并将变量作为2014-12-1作为$ dateLow和2014-12-8作为$ dateHigh,查询返回122行.数据库中有579行.过滤后返回的数据是正确的,我可以使用以下代码将其插入Excel.

    $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject();
      $phpExcelObject->getProperties()->setCreator("")
      ->setLastModifiedBy("Administrator")
      ->setTitle("ATTENDANCE DETAILS XLSX")
      ->setSubject("ATTENDANCE DETAILS  XLSX")
      ->setDescription("EXCEL document for Attendance Details");
      $phpExcelObject->setActiveSheetIndex(0);
      $phpExcelObject->getActiveSheet()->setTitle('GUARD_ATTENDANCE - DETAILS'); …
Run Code Online (Sandbox Code Playgroud)

php mysql phpexcel symfony phpexcelreader

21
推荐指数
1
解决办法
869
查看次数

PHPExcel仅在XLS文件中超出内存使用量

我在处理XLS文件时遇到了PHPExcel的内存问题.我必须处理相当大的文件(50k到200k行和9-10列),所以我不得不使用ReadFilters来解决内存问题.

但是,尽管它在XLSX文件中运行良好,但是使用混合的后台进程和一些简单的块大小计算,我无法使其与XLS文件一起使用.

这是一切爆炸的代码:

Class ExcelReadFilter implements PHPExcel_Reader_IReadFilter
{
    private $startRow = 0;
    private $endRow = 0;

    public function setRows($startRow, $chunkSize) {
        $this->startRow    = $startRow;
        $this->endRow        = $startRow + $chunkSize;
    }

    public function readCell($column, $row, $worksheetName = '') {
        if ( ($row >= $this->startRow && $row < $this->endRow) ) {
            return true;
        }
        return false;
    }
}

PHPExcel_Settings::setCacheStorageMethod( PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized );

....
$filter = new ExcelReadFilter();
$filter->setRows($desde, $cuantas);

$reader = PHPExcel_IOFactory::createReader($this->file_type);   

$reader->setLoadSheetsOnly($sheet_name);    
$reader->setReadDataOnly(false);    
$reader->setReadFilter($filter);

$chunk = $reader->load($this->file);
$chunk->setActiveSheetIndexByName($sheet_name);

$active_sheet = $chunk->getActiveSheet();
$rowIterator …
Run Code Online (Sandbox Code Playgroud)

php phpexcel phpexcelreader

8
推荐指数
1
解决办法
1414
查看次数

PHPExcel toArray跳过第一个标题行

我正在将一个excel文件上传到网站并处理它以供数据库使用.

我正在使用toArray()函数来获取php数组中的所有行.

但我想跳过第一行(标题标题行).其余行将存储在数组中.

我该如何跳过第一行.

注意:我不能使用rangeToArray()函数,因为没有固定的范围来获取行到数组.它是动态的.我想要的只是获取除第一行之外的所有行.

php phpexcel phpexcelreader

7
推荐指数
2
解决办法
1万
查看次数

在PHPExcel中复制样式和数据

我想将所有数据和某个范围的样式复制到其他单元格。例如,我要从A4:I15复制,然后粘贴,正是我要从A16复制内容和样式。我该怎么做?。这是我要复制的内容:

在此处输入图片说明

我知道只复制数据但不复制样式,并使用以下代码进行处理:

$cellValues = $objPHPExcel->getActiveSheet()->rangeToArray('A4:I15');
$objPHPExcel->getActiveSheet()->fromArray($cellValues, null, 'A16');
Run Code Online (Sandbox Code Playgroud)

我需要复制样式和数据

php phpexcel phpexcelreader

6
推荐指数
2
解决办法
8520
查看次数

读取合并的单元格PhPExcel

我正在尝试读取phpexcel中的合并单元格,我的问题是单元格合并在A:B:C:D:E:F(不能与他们想要的东西争论)

$i= 0;
foreach ($worksheet->getRowIterator() as $row) {
    if ($i > 10) break ;
    $i ++;
    $cellIterator = $row->getCellIterator();
    foreach ($cellIterator as $cell) {
        if($cell->getColumn()== 'A:B:C:D:E:F'){
            $specification=$cell->getCalculatedValue();
            var_dump($specification);die();
// some other code
Run Code Online (Sandbox Code Playgroud)

总是转储null.

我已经尝试过,$cell->getColumn()== 'A'因为单元格从A开始,但也转储为null.

我将不胜感激任何帮助.

php phpexcel phpexcelreader

5
推荐指数
1
解决办法
4653
查看次数

PHPExcel - 如何使用 phpexcel 库更改图表的颜色、边框和背景?

我正在使用 PHPExcel 库,我无法更改图表的颜色。

让我知道是否有人有解决方案?

检查此屏幕,我想更改蓝色、红色和绿色的颜色:

图像

php excel excel-2007 phpexcel phpexcelreader

5
推荐指数
1
解决办法
2614
查看次数

PHPExcel如何解决读取文件时的编码问题

我正在开发一个 Yii2 API,我需要上传一个 .csv 或 .xlsx 文件并使用 PHPExcel 读取它(现在已弃用,但我坚持使用它,因为新的 PhpSpreadsheet 需要 PHP 5.6 或更高版本)并返回数组数据的 。

这是 API 函数中使用的代码

public function actionUpload()
{
    $params = $_FILES['uploadFile'];
    if($params)
    {
        $data = array();
        $model = new UploadForm();
        $model->uploadFile = $_FILES['uploadFile'];
        $file =  UploadedFile::getInstanceByname('uploadFile');
        $inputFileName = $model->getpath($file,$data);
        //  Read your Excel workbook
        try
        {
            $inputFileType = \PHPExcel_IOFactory::identify($inputFileName['link']);
            $objReader = \PHPExcel_IOFactory::createReader($inputFileType);
            if($inputFileType == 'CSV')
            {   


                if (mb_check_encoding(file_get_contents($inputFileName['link']), 'UTF-8'))
                {
                    $objReader->setInputEncoding('UTF-8');
                }
                else
                {
                     $objReader->setInputEncoding('Windows-1255');
                     //$objReader->setInputEncoding('ISO-8859-8');
                }


            }
            $objPHPExcel = $objReader->load($inputFileName['link']);
        }
        catch(Exception $e)
        {
            die('Error …
Run Code Online (Sandbox Code Playgroud)

php phpexcel yii2 phpexcelreader

5
推荐指数
1
解决办法
8313
查看次数

PHP:如何使用科学记数法/指数格式从Excel数据中获取字符串格式的数据?

我在Yii2中有一个项目,它使用PHPExcel库来读取Excel文件.我有一个Transaction Id列,其中包含General format单元格中的数据.我的Excel文件的屏幕截图: 在此输入图像描述

你可以看到上面,如果我输入15个字符的数字并在其中放入两个点.它将显示为数字.

First Ex:输入=> 800.003.151476962在单元格中显示为 图片 并且在Formula Bar中显示为 图片

但如果在内部输入15个没有点数的字符,它将显示为科学记数法/指数.

第二个例子:输入=> 800003151476925在单元格中显示为 图片=> 科学记数法/指数数据格式,在公式栏中显示为 图片

当我尝试读取PHP中的数据时,我的PHP会将Second Ex数据读作科学记数法/指数格式而不是字符串/数字/小数.

如何在我的PHP 中将第二次Ex数据作为800003151476925(无论是字符串,数字还是十进制格式)而不是8.00003E + 14

谢谢 :)

:其实我已阅读并尝试在建议转换指数在PHP中的一个整数,转换指数数小数在PHP,转换指数数在PHP为十进制,但我什么也没得到.

php scientific-notation phpexcel exponential phpexcelreader

4
推荐指数
1
解决办法
1453
查看次数

如何使用PHPExcel从Excel文件中读取数据?

我想从PHP中的Excel文件中读取数据,以便我可以处理数据并将其插入到数据库中.
环顾四周,看起来PHPExcel是此任务的首要库.

我去了PHPExcel GitHub页面(https://github.com/PHPOffice/PHPExcel),但我无法弄清楚如何实际使用该库.有大量的示例文件,我看到的所有文件似乎都与我正在寻找的简单用例相匹配.
此外,我甚至无法确定哪些文件来自GitHub页面我甚至需要下载以及包含文件的文件夹结构需要什么.

因此,考虑到上面链接的GitHub页面的结构方式(对于v1.8),我需要下载哪些文件以及什么是简单的代码示例,它允许我提供Excel文件的路径并读取数据从文件?

php excel phpexcel phpexcelreader phpexcel-1.8.0

3
推荐指数
1
解决办法
2万
查看次数