I have a TBS Excel template with numerous sheets. I want to rename each sheet to match a variable that is going to be put into cell A2. I know Excel will not allow special characters in table names, so I can not use a square brackets to set a TBS variable.
Is there a way to change the sheet names programatically either using TinyButStrong Excel or PHP (note: PHP Excel is not an option in this environment)?
Thank you
For now (OpenTBS version 1.9.11) there is no special feature for renaming a sheet in an XLSX workbook.
Nevertheless, you can open the sub-file 'xl/workbook.xml' and replace the the old sheet name by the new one knowing that the sheet name is stored in a name attribute.
XSLX example:
<sheet name="My old sheet" sheetId="1" r:id="rId1"/>
PHP code:
$TBS->PlugIn(OPENTBS_SELECT_FILE, 'xl/workbook.xml');
$TBS->Source = str_replace('name="My old sheet"', 'name="My new sheet"', $TBS->Source);
Related
I want to modify an already existing excel sheet with delete the formula without affecting the values in the cell which are generated by those formula used in the sheets using PHP.
I tried to use php Spreadsheet. Not able to delete the formula used the excel sheets
Is there some way I can modify the already existing excel sheet with removing the formula using PHP?
I want to modify an already existing excel sheet with delete the formula used in the sheets using PHP.
I tried to use php Spreadsheet. Not able to delete the formula used the excel sheets
Is there some way I can modify the already existing excel sheet with removing the formula using PHP?
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.
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.
I have an excel file with a large amount of strings in a column. I want to add these to an array in a php file, so I want each cell in the column to be enclosed in apostrophe's and insert a comma between each. I tried copying the excel column to word and doing a find and replace in word but it uses a different apostrophe type. Any ideas?
Export the Excel file to .csv, then you can either learn to read .csv files from PHP, e.g., from this tutorial, or do something more pragmatic like open the file in a text editor like BBEdit and select the column you want using block-select mode, discarding the rest of the document.
I'm not so sure about the """ but I used a similar method to create SQL queries from cells.
="""&A1&""","""&B1&""", ...