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.
Related
I'm writing a cron php script to clean up a csv file before importing into a website db. Each row has a Quantity_Available field. My intention is to not write the rows with Quantity_Available == "0" to reduce the size of the file (14,000 records).
I'm comfortable with opening the existing file and writing it to a new file. Just not sure of the code for checking that field and skipping that line if it has that value.
Start Array:
Item, Quantity_Available, Color
Car,3,Blue
Horse,0,Brown
Motorcycle,2,Black
Expected result:
Car,3,Blue
Motorcycle,2,Black
I've don a good deal of searching here and haven't found this specific instance.
If the only thing you need to do is remove lines that have a quantity of zero and you have command line access, I suggest using grep -v ',0,' file.csv instead of writing PHP
I tried to enter the following code in my excel formula bar directly
=INDEX($E$4:$E$132,AGGREGATE(15,6,ROW($1:$30) / ($J$4:$J$132=M4), COUNTIF($M$4:M4, M4))) and works perfectly fine (the left column on the pic below).
But if I'm using my web application to generate an excel report file (PHP, using CodeIgniter and Laravel). It displays an error "'Wrong number of arguments for INDEX() function: 5 given, between 1 and 4 expected'"
Here's my sample code snippet:
$code = "=INDEX(\$E\$4:\$E\$$occurance, AGGREGATE(15,6,ROW(\$1:\$$occurance) / (\$J\$4:\$J\$$occurance=M$top_cell), COUNTIF(\$M\$4:M$top_cell, M$top_cell)))";
$ews2->setCellValue("L$top_cell", $code);
I also have tried to use the setValueExplicit method but causes the excel file to NOT precalculate the code, it reads the code as a string
$ews2->setCellValueExplicit("L$top_cell", $code, DataType::TYPE_STRING);
NOTE TYPE_STRING is provided because if TYPE_FORMULA is also used, the same output mentioned at the top occurs
Here's what it looks like using the setCellValueExplicit
May I know the right solution or quick fix for this? Thank you very much in advance!
I have found out that the PHPSpreadsheet library for PHP is yet to allow the usage of the AGGREGATE() and complicated formulas/functions, so I had found another way around
By using this excel code
=INDEX(E$2:E$38,IF(M4=M3,MATCH(L3,E$2:E$38,0),0)+MATCH(M4,OFFSET(J$2,IF(M4=M3,MATCH(L3,E$2:E$38,0),0),0,COUNT(J$2:J$38)-IF(M4=M3,MATCH(L3,E$2:E$38,0),0),1),0))
I was able to traverse through my entire range and make sure that no duplicate publication names would appear
This is in relation with the my other question -> Excel - Getting the 2nd or nth matched string from your corresponding data
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.
I'm trying to make a graph with JPGragph, but I keep getting an error saying:
JpGraph Error A plot has an illegal scale. This could for example be that you are trying to use text auto scaling to draw a line plot with only one point or that the plot area is too small. It could also be that no input data value is numeric (perhaps only '-' or 'x')
$ydata = round($ydata[0]); // An attempt to convert float to int
$ydata = (int)$ydata; // That didn't bring any solution(thought it couldn't handle float)
$pt = new LinePlot($ydata); // Here is where the error is thrown
$bar2->Add($pt);
$pt->SetColor("blue");
$pt->SetWeight(10);
I've tried to replace $ydata with an integer, but that only throws an fatal error.
Without the round and type cast, this is the var_dump of $ydata:
array(1) { [0]=> float(8.1102970953135) }
I just had the same problem using PHP 7.2 when the plot only contains one data point.
The reason seems to be that JPGraph tries to put the single data point on the left and the right edge of the plot at the same time.
Using $plot->SetCenter(); fixed the issue for me and it looks better for BoxPlots.
Working with PHP 7? I got the same error and found this:
http://jpgraph.net/doc/faq.php#F4-13
They say your PHP Installation is "faulty".
What helped me was to add a second value to the data array - only one value did just not work.
I am using xampp/wamp on windows and looking to convert an excel workbook to a html file.
I am not asking this question right away, i did a lot of research and finally managed to get to a point and got stuck here.
Am using php's COM library to open excel, then read a workbook and try to save it as html, how ever i am having issues with it
This is my code
$excel = new COM("Excel.Application",NULL,CP_UTF8) or die("Unable to instantiate Excel");
$excel->Application->Visible=1;
$excel->DisplayAlerts="False";
$workBook=$excel->Workbooks->Open(realpath("./example-03e-02.xlsx"));
$workBook->PublishObjects->Add(xlSourceSheet, "c:\\temp\\x.htm", "Sheet1", "", xlHtmlStatic, "test_27778", "");
$workBook->Publish (True);
$workBook->AutoRepublish(0);
$excel->Workbooks->Close();
$excel->Application->Quit();
$excel = null;
$workBook=null;
The PUlishObjects method keeps telling me that xlSourceSheet is not defined, i tried to pass it as a string "xlSourceSheet" but it keeps saying parameter type mismatch in one or the other. IN the above case, it says parameter 6 type mismatch;
if i remove the optional parameters like divid and title (the last 2) it shows a type mismatch on source range which empty obviously since am exporting a sheet.
Any body can shed some light on this and tell me what i am doing wrong.
Thanks
Anywyas, i managed to sort out the problem with some further digging into excel developer manual.
I just had to replace xlSourceSheet and xlHtmlstatic with their respective numbers that i found in the docs. xlSourceSheet is 1 and xlHtmlStatic is 0.
If anybody is looking for these codes, here they are
xlSourceAutoFilter 3 An AutoFilter range
xlSourcePivotTable 6 A PivotTable report
xlSourcePrintArea 2 A range of cells selected for printing
xlSourceQuery 7 A query table (external data range)
xlSourceRange 4 A range of cells
xlSourceSheet 1 An entire worksheet
xlSourceWorkbook 0 A workbook
xlHtmlCalc 1 Use the Spreadsheet component. Deprecated in Excel 2007.
xlHtmlChart 3 Use the Chart component. Deprecated in Excel 2007.
xlHtmlList 2 Use the PivotTable component. Deprecated in Excel 2007.
xlHtmlStatic 0 Use static (noninteractive) HTML for viewing only.
$object=$excel->ActiveWorkbook->PublishObjects->Add(1,"c:\\temp\\x.htm","Sheet1",0)->Publish(1);
Thanks cweiske :)