I'm trying to format numbers in an Excel file using PHP and opentbs.
Here's template code I'm working from:
[gross_pay_names;block=begin;sub1=departments][gross_pay_names.name]
[gross_pay_names_sub1;block=begin]
[gross_pay_names_sub1.val; ope=tbs:num]
[gross_pay_names_sub1;block=end]
[gross_pay_names;block=end]
The problem is in the third line:
[gross_pay_names_sub1.val; ope=tbs:num]
It always renders with an apostrophe in the beginning ('0.00). So I can't use it in other formulas in the file.
Ok, I found a solutions myself. In case anybody needs it in the future here's the template code I ended up using:
[gross_pay_names.name;block=tbs:row;sub1=departments] [gross_pay_names_sub1.val;block=tbs:cell;ope=tbs:num]
Related
I copied this code from PhpSpreadsheet's documentation and it does not work.
This example can be found on this page:
LINK to PhpSpreadsheet's documentation
From the above link
My code:
$sheet->getCell('A2')->setValue(19);
$sheet->getStyle('A2')->getNumberFormat()->setFormatCode('0000');
// will show as 0019 in Excel
But its not working and this is the result:
The expected value of cell $A2 should be 0019 but it shows 19.
Any idea on how to fix this?
Maybe you use a CSV format try to use Xlsx, I think styling in CSV is not working.
I think this is already issued and there's no solution yet. I'm also looking for the solution but the solution i only found is not use CSV.
https://github.com/PHPOffice/PhpSpreadsheet/issues/2230
I'm encountering an issue when converting docx document into HTML with PHPWord library (https://github.com/PHPOffice/PHPWord).
Here is the code snippet I use:
$phpWord = \PhpOffice\PhpWord\IOFactory::load('test.docx');
$htmlWriter = new \PhpOffice\PhpWord\Writer\HTML($phpWord);
$htmlWriter->save('test.html');
The issue is that each block of text is encapsulated in <p> tags regardless if I defined titles in the docx document. I would expect <h1> <h2>... tags to be generated. Bullet list are lost too.
Does it work as designed or did I miss something?
Thank you for your feedback.
Regards
There's a little bit of a problem when it comes to using IOFactory::load of PHPWord such as what you encountered now, depending what saved the file or what version of Microsoft Word is used to create that file. If the encoding and tags of the docx file cannot be found by PHPWord , then it will produce unexpected results
The code is fine, the problem is already with the dependency.
I'm using php xlsx writer (https://github.com/mk-j/PHP_XLSXWriter) to create my excel file and try to figure out how to force excel to make a line break.
My source data contains html tags (<br />) and i want to replace them with the correct formular. The replace function is working but i need how the string needs to be formated to force the break.
The line wrap option at format cells is enabled for the column as shown in the picture below (excel is installed german at the moment - please don't hate me for that)
What i tried so far is using CHAR(10) and CHAR(13) - altough CHAR(13) should be for mac and i am on windows.
I tried the following inputs to get my line break working. Also i tried all of the combinations with \n and \r\n instead of CHAR(10) and CHAR(13)
="text"&CHAR(10)&"text"
='text'&CHAR(10)&'text'
=text&CHAR(10)&text
The data was entered in the formular row in excel (picture below) - i think this is the only possible location to enter this isn't it?
Whatever i try my output always looks like this:
Any suggestions what i could do?
Thanks for your help!
The question got answered in https://github.com/mk-j/PHP_XLSXWriter/issues/114.
There was a release of a new brunch supporting new line character which fixed the problem.
I am reading data from a htm page into a Wordpress post with <?php include("liveresults/140403F001.htm"); ?> it works perfectly. I however need to skip the first 12 lines of the html file and only start reading from line 13. Any ideas?
If the file only contains HTML and you don't want to execute it as PHP, then you should not be using include anyway. readfile() is much better suited for that.
However, since you want to ignore the first 12 lines, you should use an SplFileObject which allows you to seek by line:
$file = new SplFileObject("liveresults/140403F001.htm");
$file->seek(12);
$file->fpassthru();
Note that if your file comes from some sort of external input, you should escape it for HTML, to guard against XSS.
It is possible to configure Eclipse PDT to format my php code after a standard like MySource or Zend?
You looking for code indentation .
I hope this may help you
http://drupal.org/node/75242
https://github.com/ginatrapani/ThinkUp/wiki/Developer-Guide:-Setting-Up-Eclipse-PDT
You can, except maybe max line length. Preferences->PHP->Code Style->Formatter will change indention.
Preferences->General->Workspace will change text file formatting (i.e; line termination)
Preferences->PHP->Editor->Typing there is an option for closing PHP tag