At the moment of this writing the current version of PHPExcel is version 1.8.0. I know how to make a chart and embed it in a worksheet, I basically followed the provided example.
Excel allows to either embed a chart into a worksheet or otherwise make a chart sheet. A chart sheet has it's own 'tab' in Excel and Excel keeps the chart scaled to the available size in the window.
Now what I would like to know is: how to add a chart sheet with PHPExcel? Is this possible with PHPExcel 1.8.0 using the 'Excel2007' writer?
As stated by #MarkBaker in the comments, the answer is simply "No" (at least not in version 1.8.1).
In my use case I was using PHP to generate an Excel workbook based on some processed data from different sources. What I did is to add VBA in Sub Workbook_Open() on the generated workbook to move the chart from a worksheet to it's own chart sheet. Then I used PHPExcel->getMacrosCode() to export the binary string of macro code to some file.
Now when generating files I add that binary string with PHPExcel->getMacrosCode(String) and save it as .xlsm instead of .xlsx. It is a bit of a hassle, but this is how I work around this problem for me.
Note that depending on your use case you might also need to generate a certificate to sign the code, to allow your user to always trust macros.
Related
I was using PHP Excel to generate a large excel, but PHP Excel consume more memory, it consume 377.37 MB memory, so now i am tried to generate excel with spout excel library
in my case i have pre-generated excel file, i want to just write value of particular cell For Ex- modify value of D48
How can i do this with spout excel?
PHP Excel allow to access and modify particular cell
$objPHPExcel->getActiveSheet()->setCellValue('D48','New value');
Is there any methods like setCellValue() in Spout
There are no direct way to do that. You can take a look at this example: https://github.com/box/spout/wiki/Edit-an-existing-spreadsheet to achieve what you need though.
Just be aware that styles are not preserved when editing a spreadsheet.
At the moment of this writing the current version of PHPExcel is version 1.8.0. I know how to make a chart and embed it in a worksheet, I basically followed the provided example and modified it to create a line chart with multiple lines / data series based on a table of numbers.
Now what I would like to know is: how to add an average line / trend line over one of the lines of my line chart? Is this possible with PHPExcel 1.8.0 using the 'Excel2007' writer?
As stated by #MarkBaker in the comments, the answer to the question is "no" (at least not in version 1.8.1).
In my use case I was using PHP to generate an Excel workbook based on some processed data from different sources. What I did is to add VBA in Sub Workbook_Open() on the generated workbook to add the trend line. Then I used PHPExcel->getMacrosCode() to export the binary string of macro code to some file.
Now when generating files I add that binary string with PHPExcel->getMacrosCode(String) and save it as .xlsm instead of .xlsx. It is a bit of a hassle, but this is how I work around this problem for me.
Note that depending on your use case you might also need to generate a certificate to sign the code, to allow your user to always trust macros.
I am using PHPExcel to read an Excel template and then write another excel file based on that model.
In my model I have 2 sheets: the first one named "Data" contains sample Data. The 2nd sheet contains a graph using the data of the first sheet.
What I'm trying to do:
replace the data of the first sheet with the new data so that the Graph automatically change.
The problem is that when I generate my excel file based on the template, the graph does'nt always appear. And when it does, there is a popup saying that he had to repair the file (I think that's because the formula of my chart refers to the data that is being replaced. PHPExcel override the data so the chart can't load).
Is there another way to achieve this with PHPExcel?
Also, I already included
$objReader->setIncludeCharts(TRUE);
and
$objWriter->setIncludeCharts(TRUE);
If something isn't clear don't hesitate to ask, I don't want to put too much useless informations for you.
I'm exporting data in excel sheet via drupal view. Drupal views_export_xls module uses
http://code.google.com/p/php-excel/source/browse/branches/class-excel-xml.inc.php?r=9
library to export data into excel sheet. Every thing working fine. But i want little more from it.
How to add MACRO in excel sheet row or cell programmatically?
Is it possible to do so by php code?
If you look at above link - line no 88 & 93 which actually create cells and rows.
What i want to create a macro and place it on excel sheet that can later convert this generated excel file into native xml (.in) file for business purpose.
I've searched a lot but most of the link suggesting VB solution and i've no sense about this language.
Can anyone point me on right direction.
Any help would be greatly appreciated!
As far as I'm aware, unless the Excel writer that you're using is based around COM, then there is no way of creating a Macro in an Excel workbook.
Please help me about my doubts on excel and php. I need to do the following process on excel report generation using php
to change cell's font styles
to change cell's BG color
to change cell's width
Try PHPExcel. I started using it few days ago and it works very good.
With PHPExcel
http://phpexcel.codeplex.com/wikipage?title=Features
http://phpexcel.codeplex.com/wikipage?title=Examples
With PEAR Spreadsheet Excel Writer
Format::setBgColor – Sets the cell's background color
Format::setFontFamily – Sets the font family.
Worksheet::setColumn – Set the width of a single column or a range of columns.
I'd definitely recommend PHPExcel as well, and it may well supercede the SEW within the PEAR repository