Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 26 13:51

    MarkBaker on Minor-Documentation-Updates

    (compare)

  • May 26 13:50

    MarkBaker on PhpStan-Cleanups

    (compare)

  • May 26 13:44
    MarkBaker closed #2529
  • May 26 13:28

    MarkBaker on master

    Declare a few return datatypes Merge pull request #2857 from P… (compare)

  • May 26 13:28
    MarkBaker closed #2857
  • May 26 13:28

    MarkBaker on master

    Declare a few return datatypes Merge pull request #2858 from P… (compare)

  • May 26 13:28
    MarkBaker closed #2858
  • May 26 13:24
    MarkBaker opened #2858
  • May 26 13:24

    MarkBaker on PhpStan-Cleanups

    (compare)

  • May 26 13:22
    MarkBaker opened #2857
  • May 26 13:21

    MarkBaker on Minor-Documentation-Updates

    Declare a few return datatypes Declare a few return datatypes (compare)

  • May 26 12:48
    Laurezi starred PHPOffice/PhpSpreadsheet
  • May 26 09:21
    GiovanniMet starred PHPOffice/PhpSpreadsheet
  • May 26 06:05
    JorgeDevmm starred PHPOffice/PhpSpreadsheet
  • May 26 05:13
    oleibman labeled #2856
  • May 26 05:09
    oleibman opened #2856
  • May 26 02:00
    CryptoDev33 starred PHPOffice/PhpSpreadsheet
  • May 26 01:14
    roelmagdaleno starred PHPOffice/PhpSpreadsheet
  • May 25 21:21
    WeTruck closed #2855
  • May 25 21:21
    WeTruck commented #2855
iamrobot
@bubigobolemeot_twitter
is there a way to set custom linear gradient colors to PHPspreadsheet pie chart?
i only managed to set custom colors
zkenstein
@zkenstein
Hello all, is anyone onow how to modify the cell value depend on id from another cell?
Something like if A1 = foo, and set cell value on B1 = bar
Sergey Popov
@windstep_gitlab
image.png

Hey, guys! I have a big problem with an corrupted xls file. And I could not understand why.

Code is as simple as i sent earlier

anand-impero
@anand-impero
i used following code and chart is created but without data so please help me
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("Flow Balance Worksheet APP Development 01032022.xlsx");
$reader->setIncludeCharts(true);
$spreadsheet = $reader->load(request()->file('file'), $reader::LOAD_WITH_CHARTS);
$sheet = $spreadsheet->getActiveSheet();
$chart = $sheet->getChartCollection();
$writer = new Xlsx($spreadsheet);
$writer->setPreCalculateFormulas(true);
$writer->setIncludeCharts(true);
$writer->save('demo.xlsx');
rohit-barman
@rohit-barman
Hi there!
vanfsy
@vanfsy
Hello
Hey, guys! I try to read several styles in a cell.
we can retrieve almost styles like font-size, font-family, bold, etc.. ,but can't get color.
Plz check it for me and let me know.
vanfsy
@vanfsy
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($inputFileName);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
$cellValue = $spreadsheet->getActiveSheet()->getCell('A1')->getValue();
if ($cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText\RichText) {
foreach ($cellValue->getRichTextElements() as $richTextElement) {
var_dump($richTextElement->getText());
if ($richTextElement->getFont()) { var_dump($richTextElement->getFont()->getColor()->getRGB()); }
}
}
Norberto Capalbo
@centraldeherramientas.drventas_gitlab
Hi, I have problem with excel generation PHPSpreadsheet when i try to download the excel, excel cant open for invalid format.

$nombreDelDocumento = "Descarga_paqar.xlsx";

Crear un "escritor"

$writer = new Xlsx($documento);

Le pasamos la ruta de guardado

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $nombreDelDocumento . '"');
header('Cache-Control: max-age=0');
$writer = IOFactory::createWriter($documento, 'Xlsx');
ob_end_clean();
$writer->save('php://output');
exit;

milomylo
@milomylo
hi everyone
shoaib2510
@shoaib2510
hi
can anyone help me link my phpspreadsheet output to phpmailer without downloading the xlsx file
6 replies
aswinkumar863
@aswinkumar863

Hi,

I have found that the useful Excel tables feature is missing in the PHPSpreadsheet library. Issue PHPOffice/PhpSpreadsheet#1816.

After some research on how the feature is implemented in exceljs, I'm planning to contribute on adding this feature to PHPSpreadsheet.

I'm here seeking any advice from the team before start working. If I file a pull request, will it merge?


Overview of Excel tables

Reasons to use Excel Tables

1 reply
ukenpachi
@ukenpachi

any idea what causes this error? Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Reader\Exception: Parameter pos=-12 is invalid

$inputFileName = "excel.xls";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
$spreadsheet = $reader->load($inputFileName);

file: https://filebin.net/sle19tm0kdgduyne/excel.xls?t=u0itbeue

Hi Alex, I am not sure if you can remember how you resolved this issue? Parameter pos=-12 is invalid

$reader = PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext);
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($file);
// Export to CSV file.
$writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv');
$writer->setSheetIndex(0); // Select which sheet to export.
$writer->setDelimiter(';'); // Set delimiter.
$writer->save($temp_storage);
DavidKirn
@DavidKirn
Hey, I have a quick question. Must Excel be installed on the system on which you want to create an Excel file with PhpSpreadsheet?
5 replies
Manish Jain
@manish-coreschedule_gitlab
Hi , i am importing style data from an excel to php and running into an error with the background color, I get 'ffffff' even thou the background is set to "No Fill".
Q. Any way to differentiate between White bg and No Fill bg when reading from file ?
El-Tommy
@El-Tommy

Hello,
How can I display a formatted time range in an Excel worksheet?

I have a range of 25:30 hours that I would like to show using HH:MM:SS format, but if I use the code below it shows as 01:30:00.

$seconds = 91800;
$spreadsheet->getActiveSheet()->setCellValueExplicit('L' . $row, (seconds / 86400) , PHPExcel_Cell_DataType::TYPE_NUMERIC);
$spreadsheet->getActiveSheet()->getStyle('L'.$row)->getNumberFormat()->setFormatCode('HH:MM:SS');

4 replies
LudovicGit
@LudovicGit
Hello,
Is that possible to lock a xlsx file? I mean lock by password when a user tries to open the file. locked to read, not locked to write.
I found few functions to add a password but it's only for write permission and not read permission
1 reply
Howitzer
@KyleHinskens
Hi, is it possible to adjust the horizontal scrollbar width with phpspreadsheet?
3 replies
shan
@shanmugamani96
hello guys,how to set limit to output data when i try to read excel data ,i need to set pagination,cant set limits ,how to resolve that?and i need to display the data as html in browser.,without null values.
Lix
@Oranzh

hello guys,how to set limit to output data when i try to read excel data ,i need to set pagination,cant set limits ,how to resolve that?and i need to display the data as html in browser.,without null values.

Why don't u save the data in other place from excel, so u can paginate it easily.

shan
@shanmugamani96
which data type do u prefer?
Lix
@Oranzh

which data type do u prefer?

Mysql, Tidb , ElasticSearch or Redis

shan
@shanmugamani96
but my problem is i need same color what I used in spreadsheet,
is it possible ?
Lix
@Oranzh
but my problem is i need same color what I used in spreadsheet,
U can store the color attribute as well, then send the all data including color to front end
U see the content that browser display is back-end returned
I think u can understand what i say
shan
@shanmugamani96
yes,thank you.
Lix
@Oranzh
Pleasure.
Lix
@Oranzh

Hi i need to show dropdown of country,state,city
based upon dropdown values should reflect,also address,streeet input box should show and hide can anyone tell me how to do using spreadsheet?

https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#setting-data-validation-on-a-cell

Here is the doc above

1 reply
sosni
@suhasini-smy
Hi,i need to show/hide rows based upon the dropdown values
1 reply
mohamedmagdy61
@mohamedmagdy61
Hello Everyone
Can you help me with a code to update a cell value without changing the other values or create a new file ?
1 reply
Brock Jameson
@bjameson72_gitlab
Hey everyone, I'm trying to save a xlsx file inside of my module and then trying to use this library to manipulate the spreadsheet data but am having trouble importing my xlsx file in the php code - I just get a "vcards.xlsx" does not exist. Any ideas on best way to access spreadsheets that are in version control?
2 replies
YueLiang
@cxx2320
how to export existing template without losing style?
图片.png
Lix
@Oranzh
image.png
9 replies

how to export existing template without losing style?

Do u refer to the documention here?

Golden Dev
@goldendev0424
Hello Everyone
How to copy style of cell by range?
It's working well when copy only one cell, but not working with range
Anh Le VN.Hanoi
@mvn-anhle-hn
Hi, has the issues with drop-lists and buttons been resolved yet? The xlsx files that I'm getting from $speadsheet->save() do not have any legacy drawing elements that the original has
PickAdmin
@PickAdmin

php7. 3 version of Excel table export prompts that the web page may not be connected temporarily, or it has been permanently moved to the new web address. Do you know why?

ERR INVALID RESPONSE

mrofia
@mrofia

Hi Everyone

I am having some issues when using getCalculatedValue. Some cells work okay in retrieving the value, but some other simply copies the formula.
Here's what I am trying to do
I want to copy the values in sheet "kirim SAP" (hidden sheet), to a separate new file. So formula containing sheet references need to be calculated before set in the new file.
Here's the source file.
https://docs.google.com/spreadsheets/d/1ShijpIDOXZhSNeUqaOh61WvRT2r7VZC5/edit?usp=sharing&ouid=109095039939818888420&rtpof=true&sd=true

Here's the output on the new file. Please mind that I expect new rows in this file for each trigger.
https://docs.google.com/spreadsheets/d/1ObN4Fnso6zigIjan1XXRV-zYC-CQFKyo/edit?usp=sharing&ouid=109095039939818888420&rtpof=true&sd=true

is there something i need to do to make it work? I checked the doc for supported formulas https://phpspreadsheet.readthedocs.io/en/latest/references/function-list-by-name/, but all that we used seem to be supported

Here's a snippet of my code to achieve this.

$lastColumn='A';
        $row=1;
        $spreadsheet->setActiveSheetIndex($spreadsheet->getSheetCount()-1);
        $sheet = $spreadsheet->getActiveSheet();
        $highestColumn = $sheet->getHighestColumn();
        $highestRow = $sheet->getHighestRow();

        $arr=array();
        try{
            for($row=1;$row<=$highestRow;$row++){
                for($lastColumn='A';$lastColumn!=$highestColumn;$lastColumn++){
                    $arr[$lastColumn.$row]=$sheet->getCell($lastColumn.$row)->getCalculatedValue();
                }
            }

            $stInsertData = $connection->prepare("insert into asmt_report_result values(DEFAULT, :template, :participant, :fields);");
            $successInsertData=$stInsertData->execute(array(':template'=>$_GET['template'], ':participant'=>$_GET['participant'],':fields'=>json_encode($arr)));

        }catch(Exception $e){
            throw $e;
        }

        $sheet->setSheetState(Spreadsheet::VISIBILITY_HIDDEN);
                $randomName=date("Ymd");
        if(empty($arr['A2'])||$arr['A2']==0){
            $randomName="candidate_".date("Ymd");
        }else{
            $randomName="internal_".date("Ymd");
        }

        $spreadsheet2 = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

        if(file_exists("../my_tmp/scpuserhris/".$randomName.".xlsx")){
            //echo "file exists";
            $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
            $spreadsheet2 = $reader->load("../my_tmp/scpuserhris/".$randomName.".xlsx");
        }else{
            //echo "file not exist";
        }




        $sheet2 = $spreadsheet2->getActiveSheet();


        $highestRow = $sheet2->getHighestRow();

        $highestRow+=1;
        for($lastColumn='A';$lastColumn!=$highestColumn;$lastColumn++){
            $sheet2->setCellValue($lastColumn.$highestRow, $lastColumn=='A'&&empty($arr[$lastColumn.'2'])?'0':$arr[$lastColumn.'2']);
            //echo $lastColumn.$highestRow."=".$arr[$lastColumn.'2']."<br/>";
        }

        $writer2 = new Xlsx($spreadsheet2);

        $filePath2 = "../my_tmp/scpuserhris/".$randomName.".xlsx";
        $writer2->save($filePath2);
3 replies