Replicate Excel worksheets dynamically - php

Is there any way to replicate Ms Excel worksheets dynamically, using openTBS on template side? im used to delimit this in Ms Word with 'Page Breaks' between the block begin and end...
What i need is
[base;block=begin]
"blablabla text...."
(Page Break)
[base;block=end]
So it can repeat all block on another page.
Is there any way to do that in Excel? But instead of a page break any other thing that will make that works in Excel :)

Unfortunately OpenTBS cannot duplicate Ms Excel worksheets yet.
This can be done with ODS (LibreOffice) worksheets but not with Ms Excel because such worksheets are not saved in a single sub-file but in several sub-files which are all referenced in other sub-file. Thus, there is not TBS block defining a worksheet.
Nevertheless, instead of duplicate worksheets you can simulate duplication by add as much empty worksheets in the template as you may need. Then delete the useless worksheets during the merge using command OPENTBS_DELETE_SHEETS. Then copy the source of the worksheet from one to another using the property $TBS->Source. Copying source of worksheets can works if there is no object such as image or chart.

Related

PHPExcel: finding page breaks after when creating worksheet on the fly

for development, i use PHPExcel (https://github.com/PHPOffice/PHPExcel) for creating a Excel (xlsx) document filled with data from a mysql database. So far this works good.
I want to print this Excel document too, as hardcopy to spread around for people reading it from paper. Printing wont be a problem.
The problem lies in: it's a long document, far more rows then will fit on 1 or 2 pages. The worksheet consists of blocks which i want to keep together, when printed, to be on the same page.
I can use a method to set breaks on a row. That i will be able to get to work. But after finishing putting the data on the sheet, i don't know where the automatically placed page breaks are. There is a function (getBreaks()) on the worksheet, which should provide an array with the breaks, but the returned array remains empty, so i can't find out which blocks go over a break.
Can someone help me?
Should i first save the Excel sheet, then open it again and do my job then?
Excel document is created on a shared hosting webserver. No printing options there i guess, at least not where i can manage them.
Other solution is: put a macro's in that Excel document, and let the macro run (to put the breaks on the right places) and print the Excel sheet. (not my favorite solution as i am honest).

How to edit pariticular cell in spout PHP excel writer

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.

Can PHPExcel add a sheet chart (as opposed to embedded chart)?

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.

How can I use PHPExcel to update a chart with different data?

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.

Adding Macro on Excel XML-specification to generate a native

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.

Categories