Tag: PHP
All the articles with the tag "PHP".
-
OpenXML in Healthcare in PHP
Here's a cool present just before the weekend... 2 days ago, Wouter posted on his blog about an article he co-operated on for MSDN: OpenXML in Healthcare. Being both a Microsoft and PHP fan (yes, you can curse me, I don't care), I thought of porting (part of) the sample code from his article into PHP. Except for the document signing, as I did not have many time to write this sample code... The scenario for the article is quite simple: Contoso provides a central medical records database. Whenever a physician has to register a new patient, he downloads a Word 2007 document from the Contoso server, fills it out, and uploads it back. Contoso then strips out the necessary data and saves it back in their systems.
-
Generic arrays in PHP
Assuming everyone knows what generics are, let's get down to business right away. PHP does not support generics or something similar, though it could be very useful in PHP development. Luckily, using some standard OO-practises, a semi-generic array can easily be created, even in multiple ways! Here's the road to PHP generics. One of the roads to PHP generics is some simple inheritance and type hinting. Let's have a look at PHP's ArrayObject. This class has 2 interesting methods, namely offsetSet() and append(). This would mean I can simply create a new class which inherits from ArrayObject, and uses type hinting to restrict some additions: [code:c#] // Example classclass Example { public $SomeProperty;}
-
Creating Office2007 documents in C#
-
PHP zip:// and parse_url...
After having a few months of problems using PHP and fopen('zip://something.xlsx#xl/worksheets/sheet1.xml', 'r'), I finally found the reason of that exact line of code giving errors on some PC's... Assuming this uses a call to parse_url under the hood, I tried parsing this, resulting in the following URL parts: Array ( [scheme] => zip [host] => something.xlsx#xl [path] => /worksheets/sheet1.xml ) That's just not correct... Parsing should return the following: Conclusion: beware when using parse_url and the zip file wrapper!
-
PHPExcel 1.3.5 released
Just a quick note on the new PHPExcel 1.3.5 release. There are some cool new features included! One of the new features is rich text: one can now write coloured and styled text in a cell. Here's an example of how the feature demo result file looks: This is of course not all. Jakub had a couple of sleepless nights, but managed to port in the PEAR Spreadsheet classes. Meaningless? No! PHPExcel now supports Excel2007 and older versions, too. Want to write an Excel document for Excel200? No problem: [code:c#] $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);$objWriter->save('excel2000file.xls'); [/code] There's even a cooler part related to this, and that is .xlsx to .xls conversion! Here's how: [code:c#]
-
OpenXML news overview
A lot of news around OpenXML these days, so I decided to bundle some things into one big blog post. In .NET 3.0, there's the System.IO.Packaging API, which allows programmatic access to OpenXML packages (amongst them Office2007 files).Since this API is quite low-level, the Microsoft people introduced a new SDK built on top of System.IO.Packaging, which allows you to use strongly typed classes for document parts. Checkout a code sample on Wouter's blog and see for yourself: this SDK provides access to an OpenXML package in a much easier way than System.IO.Packaging. Download the SDK here.
-
New PHPExcel release: 1.3.0
The new version of PHPExcel has just been released, bringing 1.3.0 to the public. New features include formula calculation, inserting and removing columns/rows, auto-sizing columns, freezing panes, ... One of the new features in PHPExcel is formula calculation. Just like Excel or any other spreadsheet application, PHPExcel now provides support for calculating certain cell values, using a formula. For example, the formula "=SUM(A1:A10)" evaluates to the sum of values in A1, A2, ..., A10. Have a look at this: if you write the following line of code in the invoice demo included with PHPExcel, it evaluates to the value "64": Another nice feature of PHPExcel's formula parser, is that it can automatically adjust a formula when inserting/removing rows/columns. Here's an example:
-
Excel Formula Parsing using PHP?
One of the new (planned) features of PHPExcel is to implement parsing and calculating Excel formulas. One thing every developer should do is not to try to reinvent the wheel. Therefore, a Google search learned me someone wrote a Excel expression parser in JavaScript, which parses an expression into a tree. Parsing Excel formulas (expressions) in JavaScript is done here. Someone ported this to C# too, and as of today, it is ported to PHP5 too 8-). The only thing left to do is building this into PHPExcel, and performing calculations using the parsed tree...
-
Excel, OpenXML and PHP
Yay! My new article on Excel, OpenXML and PHP has just been released in php|architect! A copy-paste action from http://www.phparch.com/issue.php?mid=102: "A few months ago, Microsoft released Office 2007, a version of their office suite that generates open source documents. Here, Maarten Balliauw gives an overview of the history and the politics surrounding the release before moving on to introduce his PHPExcel project, an early adoption of Microsoft's OpenXML API that enables Excel 2007 spreadsheets to be generated with PHP."
-
Workaround for PHP file_exists on ZIP file contents
Recently, I was writing some PHP code, to check if a specific file existed in a ZIP file. PHP has this special feature called "stream wrappers", which basically is a system which enables PHP to do I/O operations on streams. A stream can be a file, a socket, a SSH connection, ... Each of these streams has its own wrapper, which serves as an adapter between PHP and the underlying resource. This enables PHP to do, for example, a file_get_contents() on all sorts of streams. Assuming regular PHP file functions would be sufficient, I coded the following: [code:c#] if (file_exists('zip://some_file.zip#readme.txt')) { ... } [/code]