Zend_Gdata_Spreadsheets gives 'Namespace Error' on inserting data? - php

I'm trying to insert a row in my Google spreadsheet. While other functions like counting rows, columns etc work fine; inserting a row gives me 'Namespace Error'.
An exception of type DOMException was thrown, but did not get caught during the execution of the request. You will find information provided by the exception along with a stack trace below.
Stack Trace
1. at exception origin in ...\library\Zend\Gdata\App\Base.php line 220
2. at Zend_Gdata_App_Base->getDOM([object DOMDocument], 1, NULL)
in ...\library\Zend\Gdata\Spreadsheets\Extension\Custom.php line 64
3. at Zend_Gdata_Spreadsheets_Extension_Custom->getDOM([object DOMDocument])
in ...\library\Zend\Gdata\Spreadsheets\ListEntry.php line 77
4. at Zend_Gdata_Spreadsheets_ListEntry->getDOM()
in ...\library\Zend\Gdata\App\Base.php line 329
5. at Zend_Gdata_App_Base->saveXML()
in ...\library\Zend\Gdata\Spreadsheets.php line 336
6. at Zend_Gdata_Spreadsheets->insertRow(array('xxx', 'xxx', 'Normal', 'Lease', 'xxx', 'test', 'test'), '0Aoxxx2c')

I know this post is from a while back, but I figured I'd post anyway in the hopes of saving someone else time and headaches.
I was having this same problem and after a lot of debugging it turns out that it happens due to malformed XML.
If you're passing Key values with spaces in them, it will trigger this error.
I solved it by removing all the characters that might give the XML parser trouble.
Hope that helps.

Related

Drupal - Changing decimal field in database causes errors

I needed to change the data_scale of a decimal field implemented by the module "computed field".
I changed the field_data_MYFIELD directly in database (from 10,2 to 10,4).
I also modified the field_revision_MYFIELD the same way.
As third step, I modified the data of the field_config by changing:
FROM
s:14:"data_precision";s:2:"10";s:10:"data_scale";s:1:"2";
TO
s:14:"data_precision";s:2:"10";s:10:"data_scale";s:1:"4";
As I'm trying to clear caches with drush cc all, I get the following error:
PHP Fatal error: Unsupported operand types in
DRUPAL_SITE/modules/field/field.info.class.inc on line 495
The line 495 is:
// Make sure all expected field settings are present.
$field['settings'] += field_info_field_settings($field['type']);
I enabled the error log in index.php and have the following errors:
unserialize(): Error at offset 330 of 1314 bytes in DRUPAL_SITE/modules/field/field.crud.inc on line 374
Notice: Undefined index: settings in DRUPAL_SITE/sites/all/modules/computed_field/computed_field.install on line 13
Undefined index: settings in DRUPAL_SITE/modules/field/field.info.class.inc on line 495
Fatal error: Unsupported operand types in DRUPAL_SITE/modules/field/field.info.class.inc on line 495
What am I doing wrong?
Never a good idea to alter settings via mysql directly, take a look here to do it from code : https://drupal.stackexchange.com/questions/79378/changing-a-field-type-from-integer-to-decimal/151367#151367
Instead, you could have use an hook_update to alter the field.
Thank you Clive. I did'nt paste the whole data ...apologize. The data_precision etc keys are indeed inside a database key within that string. I tested the data content into http://blog.tanist.co.uk/files/unserialize/ (as suggested) and the string is not valid ... you were right. I fixed it by changing different values of the S lenght in order to match the content of each S . After some tests, the problem is now resolved. It appears that editing the Blob data (for computed fields with php code inside) directly from phpmyadmin is not a good idea as far as it adds many additional char that doesn't match the lenght of the S. Thanks again for your help.

PDFLib php - no more than 32 columns

I'm currently working with PDFLib 9.0.5 with PHP and I'm truggling with the building of a table.
I've got a large table with 34 columns. The first thing I do is create the header row and i've got this error message
PDFlibException' with message 'Cell in column(s) 33 and row(s) 1: Illegal array index 32 in function pdc_bvtr_setbit
I've made a test with 32 columns and there is no problems. If the array i'm using to create the row is larger than 32 elements, i've got the error.
I thought it could be due to a lack of space whithin my pdf, so i increase the pdf's width but it didn't change anything.
Here is the code which triggered the error :
foreach($this->headerTable as $index=>$text)
{
$currentOption=$optlist;
if(is_int($index))
{
$currentColorString=(($col%2)==0)?$alternateWhiteColorString:$whiteColorString;
$currentOption.=(in_array($index,array(2,3)))?' fittextflow={orientate=west}':'';
$currentOption.=($index==5)?' fittextflow={stamp=ll2ur}':'';
$currentOption.=(in_array($index,array(0,1,4)))?' fittextflow={stamp=ll2ur}':'';
}
else
{
$currentColorString=(($col%2)==0)?$greyColorString:$greyAlternateColorString;
$text=$index.' ('.$text.')';
$currentOption.=' fittextflow={stamp=ll2ur}';
}
$textFlow=PDF_add_textflow($this->pdf,0,$text,$optionHeaderContent);
$this->table=PDF_add_table_cell($this->pdf,$this->table,$col,1,'',$currentOption.' matchbox={fillcolor={rgb '.$currentColorString.'}} textflow='.$textFlow);
++$col;
}
Answer from Rainer comment : this is bug in the current version of PDFlib 9.0.5. It should be fixed in the next release.

PHP Errors after Migrating Wordpress Site

After attempting to migrate our Wordpress site to the root, the page builder theme we're using now shows the majority of the pages as blank. The page builder theme uses rows and modules with the data stored in the _postmeta table of the database. I've checked the database and the page data for the builder is still there, albeit serialized. After migrating, I did do a search and replace on the database, which I now know wasn't a good move due to the serialized data. However, I've restored the database and the site/theme files to an earlier date and the issue still persists. The site is blank! :(
I've checked the error logs for the server, and I'm noticing 3 recurring warnings starting after the migration:
Warning 1
PHP Warning: substr() expects parameter 3 to be long, string given in /hermes/waloraweb013/b1721/blu.icweb4704n/test/wp-content/themes/cutting-edge/framework/spyropress-functions.php on line 105
Line 105 reads:
$text = substr( $text, 0, $length );
Warning 2
PHP Warning: Invalid argument supplied for foreach() in /hermes/waloraweb013/b1721/blu.icweb4704n/test/wp-content/themes/cutting-edge/framework/builder/spyropress-row-functions.php on line 382
The code for line 382 is:
foreach ( $rows as $row_ID => $row ) {
Warning 3
PHP Warning: Invalid argument supplied for foreach() in /hermes/waloraweb013/b1721/blu.icweb4704n/test/wp-content/themes/cutting-edge/framework/builder/spyropress-row-functions.php on line 332
Line 332 is also:
foreach ( $rows as $row_ID => $row ) {
I need help figuring out what could've gone wrong and still be wrong after restoring the site and the database to an earlier time, and without changes in of the Lines which now have errors. Is it possible that the database is caching? I've cleared my browser cache and restarted several times to no avail.
Any help or insight is greatly appreciated - we're talking about 8 months worth of work I really can't afford to lose.
Thanks in advance!

How to insert huge formulas in PhpExcel?

Need your help with problem:
I need to Insert Formulas in the cells.
Simple Formulas like =A1+A2 are uploading OK.
But such as "=(C18100%/D18)100%" don't upload. Just empty cells.
Also as i'm from Ukraine, i need to upload formulas in my own language. Example:
=(((((C17(1-(Скидка+НакопСкидка))(1-Самовывоз)))(1-ПоФакту)))(1-Скидка_Упаковка))
Attemp to upload such formula gives an error:
Fatal error: Uncaught exception 'PHPExcel_Calculation_Exception' with message 'Лист3!G17 -> Formula Error: Expecting ')'' in /var/www/zoobonus/zoobonus.ua/php_classes_2.1/Classes/PHPExcel/Cell.php:300 Stack trace: #0 /var/www/zoobonus/zoobonus.ua/php_classes_2.1/Classes/PHPExcel/Writer/Excel5/Worksheet.php(460): PHPExcel_Cell->getCalculatedValue() #1 /var/www/zoobonus/zoobonus.ua/php_classes_2.1/Classes/PHPExcel/Writer/Excel5.php(187): PHPExcel_Writer_Excel5_Worksheet->close() #2 /var/www/zoobonus/zoobonus.ua/templates/account/price_list/blank_for_all.php(75): PHPExcel_Writer_Excel5->save('/var/www/zoobon...') #3 /var/www/zoobonus/zoobonus.ua/admin/outlet_report.php(45): include('/var/www/zoobon...') #4 {main} thrown in /var/www/zoobonus/zoobonus.ua/php_classes_2.1/Classes/PHPExcel/Cell.php on line 300
How to fix this problems?
=(C18100%/D18)100%
is not a valid excel formula (missing operator between (C18100%/D18) and 100%
=(((((C17(1-(Скидка+НакопСкидка))(1-Самовывоз)))(1-ПоФакту)))(1-Скидка_Упаковка))
Are those named ranges (e.g. Скидка) that you're using in that formula?
I don't believe that C17 is a function in MS Excel, but it looks as though you are using it as one here.
Another problem lies in the lack of operator between -(Скидка+НакопСкидка)) and (1-Самовывоз))) and between (1-Самовывоз))) and (1-ПоФакту))) and between (1-ПоФакту))) and (1-Скидка_Упаковка))
I never realised that MS Excel allowed you to link operands without any operator, and can't find any version of MS Excel that will actually allow me to enter such a formula without complaining about it, so again I'd suggest that it is an invalid formula.
=(C18*100%/D18)*100% - i have repair the formula. It still doesn't want to insert in the cell. Why?
=(((((C17(1-(Скидка+НакопСкидка))(1-Самовывоз)))(1-ПоФакту)))(1-Скидка_Упаковка)) - thanks, it was really invalid formula, words like "Скидка" are links on cells. So i repeaired it on =(1-D7)*17 and it inserts now.

Formula error in PHPExcel

i have a strange issue with phpexcel on a pair of formulas and can't figure the source of the problem. (Other simple math formulas work, only this fails).
Since the php report is quite long i'll get straight to the point.
Setting this formula like this
$objPHPExcel->getActiveSheet()->setCellValue("D$cuenta_empleados", "=$'asientos_title'.K$cuadro_row" );
Throws me this
Fatal error: Uncaught exception 'Exception' with message 'INPUT NOMINA Agosto!D8 -> Formula Error: An unexpected error occured' in /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Cell.php:293 Stack trace:
#0 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Writer/Excel5/Worksheet.php(455): PHPExcel_Cell->getCalculatedValue()
#1 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Writer/Excel5.php(194): PHPExcel_Writer_Excel5_Worksheet->close()
#2 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/classes/Everything.class.php(2361): PHPExcel_Writer_Excel5->save('../../reports/1...')
#3 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/classes/Everything.class.php(3813): Everything->create_act_entry(Array, Array, Array, Array, Array)
#4 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/controllers/common/generar.php(68): Everything->gen_docs(Array, Array, Array)
#5 {main} thrown in /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Cell.php on line 293
So to debug it i remove the = to avoid it's calculation. I check it on openoffice. And i see
'ASIENTOS Agosto'.K4
And adding the = in front of it works.
The second formula i have issues it's a condition one (same issue, it can generate it but it works on php)
=IF(D22>O22;D22-O22;0)
The developer documentation states that you need to us US/UK separators in formulae.
Quoting:
4.6.4. Write a formula into a cell
Inside the Excel file, formulas are always stored as they would appear in an English version of Microsoft
Office Excel, and PHPExcel handles all formulae internally in this
format. This means that the following rules hold:
• Decimal separator
is '.' (period)
• Function argument separator is ',' (comma)
• Matrix
row separator is ';' (semicolon)
• English function names must be used
This is regardless of which language version of Microsoft Office Excel
may have been used to create the Excel file.
so
=IF(D22>O22,D22-O22,0)
rather than
=IF(D22>O22;D22-O22;0)
The only exception that applies is if you have set locale settings for formulae as described in section 4.6.5 of that document
The separator for a worksheet in a cell reference is the exclamation mark:
'ASIENTOS Agosto'!K4
not
'ASIENTOS Agosto'.K4
Formula pre-calculation
By default, this writer pre-calculates all formulas in the spreadsheet. This can be slow on large
spreadsheets, and maybe even unwanted. You can however disable formula pre-calculation:
$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
$objWriter->setPreCalculateFormulas(false); isso resolver
$objWriter->save("05featuredemo.csv");
Im using this PHPExcel class for database import purposes and i got the same error.
Some debugging showed, that this content of a table cell caused the error:
=- die Beschaffungsplattform für Geschäftskunden
I figured out, that the exception is thrown on purpose at:
PHPExcel/Classes/PHPExcel/Cell.php on line 288 (current PHPExcel Version v1.7.6)
throw(new Exception($this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()));
So i just deleted this exception and returning an empty string instead:
$result = "";
Its a bad Workaround but works like a charme :)

Categories