Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Med-Seif
@Med-Seif

Is there a way to apply a border style for a range of cells other than the default method :

$spreadsheet->getActiveSheet()->getStyle('A1:E10')->getBorders()->getTop()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK);

This method applies the border for the whole block and not each cell

Fräntz Miccoli
@frantzmiccoli
@Med-Seif I am pretty sure you have utilitary function than could give you a cell array from a cell range. like A1:E10 --> ['A1', 'A2', ...]
amosfolz
@amosfolz

@Med-Seif I think you may find this helpful: https://phpspreadsheet.readthedocs.io/en/develop/topics/recipes/#styles
You can use allBorders like

$stlyes = [
  'borders' => [
        'allBorders' => [
            'borderStyle' => Style\Border::BORDER_THICK,
        ]
]

This will apply border to each cell in the range you have selected, rather than to just the outer cells.

Miguel Ángel Sánchez Palafox
@gueroverde
Hello, there is a way to format as a table?
Angelo D'Errico
@angeloderrico_gitlab
Hello, there is anyone that solved secondary Y-Axis for Charts?
@IPMegladon Hi, have you solved your issue on secondary Y-Axis?
LauKL1991
@LauKL1991

Hello all,

Is there any way to open a password protected excel file? Given the password always be the same. (Or it is better i can pass/key in the password to open the file).

Thanks.

Megladon
@IPMegladon
@angeloderrico_gitlab
No I haven't I wasnt able to fully understand the implementation of the axis and
Therefore couldnt write the code for reading and writing the secondary axis as well
Med-Seif
@Med-Seif
@amosfolz Thank you, that helped me a lot, I found that I wanted from The additional shortcut borders in addition to allBorders : horizontal, vertical etc...
@frantzmiccoli Thank you, that should be interesting but I prefer apply a style on a range of cells performance needs
hschaaps
@hschaaps
Hi, we are trying to modify an excelsheet with PhpSpreadsheet but we are having issues with the LINEST formula not behaving the way it does in excel. In Excel it is possible to set a multidimensional array like this: =LINEST(T41:T51;K41:L51;1;1), however PhpSpreadsheet seems to require that both arrays are the same size. Is there a way to work arround this limitation?
eelmasllari
@eelmasllari
Hi! Is there a known problem with PhpSpreadsheet loading xlsx files with a chart sheet? I have a very simple file with only two sheets, one with the data (3 numbers), and the other sheet is a pie chart of those 3 numbers (not as object in a sheet - the whole second sheet is a chart). When I try to read the file, I get a Notice: Undefined index: rId2 in phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line 754. If the chart is as object in a normal sheet, the problem does not occur. Any clues/workarounds? Versions: PhpSpreadsheet 1.6, PHP 7.1.12, xlsx file created with Excel 2011 for Mac. Thanks!
(The Notice itself doesn't disturb me much, but the fatal error it causes does: Uncaught TypeError: Argument 1 passed to PhpOffice\PhpSpreadsheet\Reader\Xlsx::readColumnsAndRowsAttributes() must be an instance of SimpleXMLElement, boolean given)
ndumngalon
@ndumngalon
Hi Guys :) just wanna ask if anybody here was able to make the axis labels overlapping?Thanks in advance. BTW im trying it on a bar graph :)
Tolga Ozses
@kartagis
hello
luisbessa
@luisbessa
hello, is it possible to set a range of cells as a table ? i failed to find information about it
Flávio Alves
@flavio-alves
Hey guys, I can easily insert an image inside a sheet and at specific cell coordinates, but how can I set the cell dimensions to fit the image dimension?
Mark Baker
@MarkBaker
@PowerKiKi How do we push the documentation from /docs in the github repo to phpspreadsheet.readthedocs.io?
Adrien Crivelli
@PowerKiKi
image.png
@MarkBaker docs are published automatically on every single push. It was stuck for a while because I forgot to remove the develop branch. It now correctly builds from master branch as expected.
@MarkBaker If you create an account, and give me your username, I'll gladly add you as a third maintainer, so you can access everything, and we can reduce the bus factor
Mark Baker
@MarkBaker
Thanks, I wasn't sure that the push was automatic, because I didn't see the first changes that I merged to master appearing in the docs... I'll set myself up with an account on readthedocs today
I'll also be looking at doing a tagged release over the coming week
Adrien Crivelli
@PowerKiKi
@MarkBaker cool, I usually try to treat all PR before a release (at least reviewing and maybe merging), but I don't have much time nowadays... I'll see what I can do, but don't hold your breath...
Adrien Crivelli
@PowerKiKi
It would be nice if you could have a look at #844 though...
Kiko
@KikoSt
Hi there! Just a quick question, hopefully ... I simply cannot get my charts (simple pie for now) to change font size etc. - I guess a tiny hint might be all I need, changing style in the spreadsheet itself is no issue at all, I just don't get the chart stuff done :O
_
MassiPi
@MassiPi
hello!
i can't find a way to open password protected xls and xlsx files with phpspreadsheet, am i missing something?
Emmanuel Lanuzo
@GeneralKenobee_gitlab
Hi. Anyone on the maintainers side?
Emmanuel Lanuzo
@GeneralKenobee_gitlab
In phpoffice\phpspreadsheet\src\PhpSpreadsheet\Reader\Csv.php. canRead function always fails to parse the file or guess its extension since of course it is a tmp file. Anyone can fix this?
odlarhg
@odlarhg
Hi, I'm new here. I hope you can understand me I speak a little bit english. I am trying to use phpspreadsheet with scriptcase. When I run the application I get this error message "Parse error: syntax error, unexpected 'use' (T_USE)". Can someone help me?
Fräntz Miccoli
@frantzmiccoli
@odlarhg This has nothing to do with PHPSpreadsheet most likely. You are calling use when you shouldn't, probably a missing semi colon ";" I would say. If you enable error display you should be able to see the line at which the error is occuring, check this line and the few lines before it.
odlarhg
@odlarhg
@frantzmiccoli I have checked the code lines and there is no missing semicolon. I am testing one of the example codes that includes PHPSpreadsheet and I have not included any additional lines. Most likely the problem is generated by scriptcase and not by PHPSpreadsheet. I tried to use the PHPExcel library, but unfortunately all xls or xlsx files that it generates are always corrupt. Because of this, look for using phpspreadsheet.
MassiPi
@MassiPi
well something like that can be sourced for example trying to access $array[use] instead of $array['use'].. why don't you paste that line of code?
odlarhg
@odlarhg

use PhpOffice\PhpSpreadsheet\Spreadsheet;

require DIR . '/../Header.php';

$spreadsheet = new Spreadsheet();
$helper->log('Create new Spreadsheet object');
$spreadsheet = new Spreadsheet();

// Set document properties
$helper->log('Set document properties');
$spreadsheet->getProperties()
->setCreator('Maarten Balliauw')
->setLastModifiedBy('Maarten Balliauw')
->setTitle('PhpSpreadsheet Test Document')
->setSubject('PhpSpreadsheet Test Document')
->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
->setKeywords('office PhpSpreadsheet php')
->setCategory('Test result file');

// Add some data
$helper->log('Add some data');
$spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!');

// Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');

$spreadsheet->getActiveSheet()
->setCellValue('A8', "Hello\nWorld");
$spreadsheet->getActiveSheet()
->getRowDimension(8)
->setRowHeight(-1);
$spreadsheet->getActiveSheet()
->getStyle('A8')
->getAlignment()
->setWrapText(true);

$value = "-ValueA\n-Value B\n-Value C";
$spreadsheet->getActiveSheet()
->setCellValue('A10', $value);
$spreadsheet->getActiveSheet()
->getRowDimension(10)
->setRowHeight(-1);
$spreadsheet->getActiveSheet()
->getStyle('A10')
->getAlignment()
->setWrapText(true);
$spreadsheet->getActiveSheet()
->getStyle('A10')
->setQuotePrefix(true);

// Rename worksheet
$helper->log('Rename worksheet');
$spreadsheet->getActiveSheet()
->setTitle('Simple');

// Save
$helper->write($spreadsheet, FILE);

The first line is the one that generates the error.
MassiPi
@MassiPi
what did you put before? wjere did you put that "use"? it can't be within a method
odlarhg
@odlarhg
There is nothing before. It is the first line of the file. Take the code of the example file and in Scriptcase I inserted it into an application that Scriptcase calls Blank.
_
MassiPi
@MassiPi
so noone ever tried to open a password protected excel file with phpspreadsheet?
odlarhg
@odlarhg
Hello,I have been able to solve the problem in order to create an xlsx file with phpspreadsheet inside a Scriptcase application. I do not know if it is the most correct solution, but at least it allows me to create the file. Now I have to customize my code to export the data I need, but I think I'm on the right track. I leave the code in case someone is useful.

$contenido="<?php
require ('../../../vendor/autoload.php');

use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;".'

require_once "../../../vendor/phpoffice/phpSpreadsheet/src/Bootstrap.php";

$helper = new Sample();
if ($helper->isCli()) {
$helper->log("This example should only be run from a Web Browser" . PHP_EOL);

return;

}
// Create new Spreadsheet object
$spreadsheet = new Spreadsheet();

// Set document properties
$spreadsheet->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");

// Add some data
$spreadsheet->setActiveSheetIndex(0)
->setCellValue("A1", "Hello")
->setCellValue("B2", "world!")
->setCellValue("C1", "Hello")
->setCellValue("D2", "world!");

// Miscellaneous glyphs, UTF-8
$spreadsheet->setActiveSheetIndex(0)
->setCellValue("A4", "Miscellaneous glyphs")
->setCellValue("A5", "éàèùâêîôûëïüÿäöüç");

// Rename worksheet
$spreadsheet->getActiveSheet()->setTitle("Simple");

// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$spreadsheet->setActiveSheetIndex(0);

// Redirect output to a client’s web browser (Xlsx)
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");'.'
header("Content-Disposition: attachment; filename=' . "01simple.xlsx".'");
header("Cache-Control: max-age=0");
// If you are serving to IE 9, then the following may be needed
header("Cache-Control: max-age=1");

// If you are serving to IE over SSL, then the following may be needed
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: cache, must-revalidate"); // HTTP/1.1
header("Pragma: public"); // HTTP/1.0

$writer = IOFactory::createWriter($spreadsheet, "Xlsx");
$writer->save("php://output");

$spreadsheet->disconnectWorksheets();
unset($spreadsheet);?>';

$file = fopen("prueba2.php", "a");
fwrite($file, $contenido);
fclose($file);
header ("Location: prueba2.php");

odlarhg
@odlarhg
Por cierto gracias al comentario de José Renteira que me ayudó a encontrar una solución. https://plus.google.com/114583721646550413124/posts/DkCnhC65wJ2
By the way, thanks to José Renteira's comment that helped me find a solution . https://plus.google.com/114583721646550413124/posts/DkCnhC65wJ2
Adrien Crivelli
@PowerKiKi
MassiPi
@MassiPi
@PowerKiKi isn't it for SETTING security on newly created files? i'm trying to OPEN an excel file password protected..
Fräntz Miccoli
@frantzmiccoli
@MassiPi columns headers says whether or not you are looking at readers or writers
MassiPi
@MassiPi
oh god that was so clear lol :) i did not find any code example for a reader opening a password protected file, can you help me?