Date calculation with PHPExcel library - php

I have a php script that have to parse an excel file with some date and time to import in my mysql database
Screen of the xlsx file :
I'm using the PHPExcel library to read the file
When I get the cell value with getValue() method, it returns the formula =J4+"01:00:00" as showed in the excel formula field. Ok normal
When I use the the getCalculatedValue() method, it returns "#VALUE!". As excell / Libreoffice don't have any problem to calculate the formulas, I have no idea why the PHPExcel library is not able to calculate this quite simple formulas.
Do anyone had the same issue and know a trick to fix this issue ? Or do I realy have to tell users not use any formulas fort date fields type ?

I found the answer from the PHPExcel support platform.
The only way to manage this kind of formulase (date operation) is to replace my actual formulas by something like =J4+(1/24)
Source : PhpExcel support plateform

Related

php output sql to excel

How can I use php sql to export to Excel and NOT csv/tsv?
I have googled for it for a while but am only finding multiple results on exporting to csv.
Even if you just point me to the name of the method I can google it from there.
Thanks
You can use a lib like phpExcel or Spout to create (and read) excel files.
phpExcel : lots of options, but slow
spout : less options, but much faster than phpExcel

Convert excel xlsx to xsl in php for php-excel-reader

I have to code a PHP platform for importing an Excel file (quite heavy) to fill an SQL server database.
To do so I used the library PHP-excel-reader (https://code.google.com/archive/p/php-excel-reader/downloads) to be able recover the value of specific cells (eg $ water = $ data-> val (13, 'A');) everything works fine except that PHP-excel-reader is only compatible with .xls not .xlsx, if I go directly convert my files in excel no problem.
But so that the user does not have to do this operation every time I want automated converting .xls .xlsx has.
I tried to use PHPExcel (http://phpexcel.codeplex.com/) but nothing works all the file converted by the libraries do not work on PHP-excel-reader. Would you have a solution?
If there is no solution do you have knowledge of another library that allows like PHP to store the value of an Excel cell in a variable?
I am desperate. Thank you in advance for your help. Sorry for my English I'm french x)
For those interested, I found a solution. It is used the SimpleXLSX library (http://www.spyrozone.net/hacking/2011/05/php-parse-and-retrieve-data-from-xlsx-files.jsp), it will return from to an .xlsx an array of values where it will be to recover each cell value. if you have a problem with date conversion check this ( https://www.ablebits.com/office-addins-blog/2015/07/01/excel-convert-time-decimal/)

phpexcel with Bloomberg

I am trying to create an Excel workbook using PHPExcel...
Everything works fine with most of the columns I'm creating.
However, the last column contains a formula (BDH) which belongs to Bloomberg's Excel Addin. This workbook will be used, of course, on a Bloomberg Terminal.
PHPExcel returns an error when I try to enter the Bloomberg formula on this column. I have successfully entered regular formulas in the column, so I assume the problem is that PHPExcel doesn't know the Bloomberg formula I am entering...
Any thoughts?
$Formula="=BDH(\"$My_Asset\" , \"px_last\" , \"$My_Date\" , \"$My_Date\" , \"$My_Overrides\" )";
$objPHPExcel->setActiveSheetIndex(0)->setCellValue("G1",$Formula);
Thanks in advance!
You're correct in your assumption: PHPExcel will only work with functions that are "native" to Excel itself, not with functions that are added to Excel through external packs, nor with User-Defined functions. Nor is there any method of adding these non-native functions.

countifs function with multiple conditions in excel file causes phpExcel to crash

I'm using phpExcel class in a project.
I created a model file with some formulas in its 2nd sheet which takes the data from 1st sheet. I'm writing all the data in the first sheet with phpExcel. Most of the formulas are working very well but there is one formula that causes a problem which is
=COUNTIFS(data!$R$2:$R$2000;"<>0";data!$R$2:$R$2000;"<=90")
for the Excel 2007, the syntax differs in newer verison of Excel like
=COUNTIFS(data!$R$2:$R$2000,"<>0",data!$R$2:$R$2000,"<=90")
I tried to write both formula to the cell with phpExcel also but it didn't work either. When I use this formula , I get no error or feedback , the script just stops working.
I would be glad if you could show me a way to solve this issue.
Regards
From the FunctionListByName.txt document in the PHPExcel /Documentation folder:
COUNTIFS CATEGORY_STATISTICAL *** Not yet Implemented

Convert Excel spreadsheet to PHP script

I have an excel spreadsheet that contains some formulas to calculate ROI for an upcoming product of a client. Is it possible to convert this into a php script whereby a user would type into some boxes and then submit it working out the same. The excel spreadsheet is here: http://www.solidcamxpress.co.uk/roi.xls
Sure, PHP can do math just like Excel's formulas. However, there is no magic method of converting Excel to a Web page, if that's what you're asking.
#Cameron
There is a software in the market which can convert the spreadsheet to active html/php with ease. You can get the software at the following url:
http://www.spreadsheetconverter.com
Even you can also convert the spreadsheet by yourself as it is simple to convert with scripts. but you can also this software for the conversion =)
You can use PHPExcel to read an existing spreadsheet and extract its data/formulas, but converting those formulas from Excel syntax to PHP is rather non-trivial.
Unless you're doing a generalized Excel->PHP converter, the time/effort required to write such a converter will be far greater than it would take you do analyze the one spreadsheet by hand and code up some PHP stuff to recreate it.

Categories