Business IT - Technology for your business

No. 1 Story

Telstra adds one million mobile services, but Sensis plummets

Telstra has revealed the addition of almost one million new mobile services in the six months to December 2011, but Sensis revenues plummeted 24 percent in 12 months.

read more

Linux and Windows interoperability with OpenXML

Business IT - Open Source

Secondly, it does have to be said, if you’re sending an Excel document there’s a safer pragmatic bet the recipient has either Excel or an Excel-compatible spreadsheet application than any other format. True, at this time Office 2007 doesn’t have a major foothold but this will undoubtedly grow.

Now, perhaps dynamic creation of invoices isn’t really your cup of tea. Where this bit of code really is terrific though is that it itself is only serving to demonstrate a larger piece of work by the author – namely, a reusable open source library of Excel 2007 reading/writing routines called PHPExcel.

The implemented features thus far are quite impressive; an in-memory spreadsheet can be represented, with worksheets, data and formulas. Protection is enforced as is formatting including expected font changes and more complex items like gradient fills. Images may be added and various styles set, along with printing options and saving to several file formats.

Having a library like this means that all the complex work involved in reading and writing the OpenXML format is taken care of. The main app becomes merely a dead simple sequence of calls like so, allowing the developer to focus on the problem at hand:

include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice');
$objPHPExcel->getActiveSheet()
->getStyle('B1')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->setCellValue('E4', '=C4*D4');
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save(‘invoice.xlsx’);


Producing Excel documents in PHP has never been easier.

Creating Word documents in pure Java

Continuing the trend, another team of developers have devised Java code which generates valid OpenXML word processing documents without any use of the Office client applications, or any Microsoft APIs or libraries, and indeed, without even requiring a Microsoft operating system.

The intention of this code is to assist developers who work in Java on Linux or Macintosh or any other non-Microsoft environment, and also developers building server-side applications that wish to produce Office-compatible documents to present data and reports.

Actually, to be precise, OpenXML covers a set of XML document standards; SpreadsheetML is the subset relating to spreadsheeting which PHPExcel is striving to implement, and this Java code actually implements the WordProcessingML side of OpenXML.

More coders have jumped in with Java snippets. Another sample shows creating a document, adjusting its properties and thumbnail, adding text and converting to HTML output. and several more can be found.

The pinnacle of them all, however, is OpenXML4J – an open-source library for Java developers that provides classes for OpenXML development. It’s in pure Java meaning it’s usable anywhere you have a standard Java compiler and library and runtime. Just like PHPExcel, this library can be used by developers to manage all the mechanics of OpenXML document construction and manipulation making working with Word/Excel and PowerPoint documents a breeze on any platform.

ODF to OpenXML and back again

Another project gaining traction is the ODF to OpenXML translator package. This title is potentially misleading; the project doesn’t just convert ODF (Open Document Format) documents to OpenXML but also allows conversion the other way. This is actually among the top 25 projects on SourceForge.

The development goals for this team are to make plugins that provide interoperability between applications based on ODF and OpenXML. A core deliverable is the development of add-ins for Microsoft Office which permit both opening and saving of ODF files. Unfortunately, no such add-ins appear to be underway or planned for OpenOffice but a secondary deliverable is a series of command-line translator utilities to perform batch conversions in either direction. These utilities can also be run on servers, invoked by server-side applications.



- sponsored feature -

The Death of Traditional BI: What’s Next?

How to Make Business Discovery Work for Your Business IP PABX BUYING GUIDE

Business Discovery takes its cues from consumer apps. Like Google, it encourages us- ers to hunt for and explore data without worrying about or even noticing the underly- ing technology. Their entire experience is working within an intuitive interface to get real-time, self-service results with only minimal training. ...more