Excel plugin for silex
- xls and xlsx support in excel_compute script
Use PHPExcel to set values and get values from an Excel sheet. The result is an RSS feed which you can use in Silex with the Oof RSSConnector component. Formulas of the cells are interpreted thanks to phpExcel.
You can set the values you want and get other cells which are supposed to contain the result.
For example if you want to display a list of prices for some fruits at a given
Let’s say the day is set in excel in the column A1, the labels are in the column B and the prices are formulas in the column C. You want to display a list with all fruits and their prices.
So you simply put the Oof components on the Stage in silex:
- URL prefix = < < silex.rootUrl> > /cgi/scripts/
- enter the connector and list names
- source = excel_compute.php?set_values=A2:DATE&get_values=B2-C5&file_name=media/test_xls.xlsx - but replace “DATE” by the date you want (if it is different from the one which is in the excel file allready). The “DATE” value can be entered by the user for exemple or be the date of today (use silex accessors)
- cell content = < < B> > costs < < C> > Euros
It makes this happend:
The script which you call with the Oof components
- get_values values to be retrurned - may be a range - e.g. A1,C2-F15,G6
- file_name name of the xlsx file
- sheet_number sheet number - default is 0
An RSS2 feed with all the desired cells. Title tag is the line number, other tags have the name of the column and the value of the corresponding cell (col,line).
For example, the items could be like
<I><![CDATA[EUR]]></I> </item> <item> <title><![CDATA]></title> <G><![CDATA[Pommes]]></G> <H><![CDATA]></H> <I><![CDATA[DOLAR]]></I> </item>
The following requirements should be met prior to using PHPExcel:
PHP version 5.2 or higher
oof components and silex
copy includes/phpexcel/ folder into [silex installation folder]/cgi/includes/
copy excel_compute.php to [silex installation folder]/cgi/scripts/
copy test_xls.xlsx in [silex installation folder]/media/
call the script like
- call the script without any parameter to display help