Comments (24)
use is_integer($F{rowIndex}/2) into printWhen property on band, create a two bands
from jasperphp.
I understand is because I don't have this rowIndex in the select, wouldn't it be more interesting to support this conditional no?:
($V{COLUMN_COUNT}% 2) == 0
from jasperphp.
You can add here
Line 30 in c1a338d
from jasperphp.
As you guide requires two bands, I tried something simpler using a rectangle and applying the print condition on it, but it didn't work... are these conditionings also ready for rectangle?
from jasperphp.
but mind you, jasper report has style functionality and in a style we can add conditional formatting, where can i be testing and modifying to support conditional formatting of the style?
from jasperphp.
I understand now, but i´m sorry, i never use it, where in jasperstudio can be access it ?
from jasperphp.
I found styles, i think what a way to support this
in
Line 78 in c1a338d
add a function to read each style and store into a global array, and all objects what you want to use styles, load style property into a object, (all objects are a separate Class) and use styles properties to decore that element, but yet no locate conditional styles, help me about this and i help you to think a way to do this.
from jasperphp.
thanks for the support, come on I'll demonstrate what I've achieved so far
from jasperphp.
in Report.php on line 68 I added the following debugging:
//echo $className."<br/>";
if(ucfirst($obj)=='Style'){
echo "<br/><br/>".$className."<br/>";
print_r($value);
echo "<br/><br/>";
if(isset($value->conditionalStyle)){
echo "conditionExpression: ".$value->conditionalStyle->conditionExpression;
echo "<br/>";
//get definition style condicional
$style= $value->conditionalStyle->style->attributes();
var_dump($style);
echo "<br/>";
echo "mode: ".$style['mode']."<br/>";
echo "backcolor: ".$style['backcolor']."<br/><br/>";
}
}
e o result is:
JasperPHP\Style
SimpleXMLElement Object ( [@attributes] => Array ( [name] => Title [fontName] => Times New Roman [fontSize] => 50 [isBold] => true ) )
JasperPHP\Style
SimpleXMLElement Object ( [@attributes] => Array ( [name] => SubTitle [forecolor] => #736343 [fontName] => Arial [fontSize] => 18 ) )
JasperPHP\Style
SimpleXMLElement Object ( [@attributes] => Array ( [name] => Column header [forecolor] => #666666 [fontName] => Arial [fontSize] => 12 [isBold] => true ) )
JasperPHP\Style
SimpleXMLElement Object ( [@attributes] => Array ( [name] => Detail [fill] => Solid [scaleImage] => FillFrame [markup] => none [fontName] => Arial [fontSize] => 12 ) [conditionalStyle] => SimpleXMLElement Object ( [style] => SimpleXMLElement Object ( ) ) )
conditionExpression:
object(SimpleXMLElement)#9 (0) { }
mode:
backcolor:
JasperPHP\Style
SimpleXMLElement Object ( [@attributes] => Array ( [name] => Row [mode] => Transparent [backcolor] => #EDE8E8 [pattern] => ) [conditionalStyle] => SimpleXMLElement Object ( [conditionExpression] => $V{COLUMN_COUNT}%2 == 0 [style] => SimpleXMLElement Object ( [@attributes] => Array ( [mode] => Opaque [backcolor] => #F0F0F0 ) ) ) )
conditionExpression: $V{COLUMN_COUNT}%2 == 0
object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(2) { ["mode"]=> string(6) "Opaque" ["backcolor"]=> string(7) "#F0F0F0" } }
mode: Opaque
backcolor: #F0F0F0
from jasperphp.
however, for this to be possible, it is necessary to make an adjustment in the initialization of the xml, I see that I modified it, I would have to see if this affects your structure used so far, but this way it displays the conditional expression of the style:
$xml = simplexml_load_string($xmlFile,null,LIBXML_NOCDATA);
from jasperphp.
as in the definition of objects, for example, in TextField there is the property style with the name of the style, I believe it is possible to search the definition of the style and apply the conditional
from jasperphp.
i hope what the best way is it
// atribui o conteúdo do labelif(ucfirst($obj)=='Style'){
$this->addStyle($obj); // create a new method into Report.php
}
puclic function addStyle($style){
$this->arrayStyles[] = $style; // here you can trate all parameter of style
}
make this, for example in texfield you get the style property and this line you can get the report object
Line 22 in c1a338d
you can get $obj->arrayStyles and use it to decorate a element
from jasperphp.
following your idea I created methods and I can apply exactly the style definitions, all the definitions: background, color and etc... this in TextFiel for now... now I need to see how to apply the conditional style...
in Report.php
add
public $arrayStyles;
add
//echo $className."<br/>";
// atribui o conteúdo do label
if(ucfirst($obj)=='Style'){
$this->addStyle($value); // create a new method into Report.php
}
new methods
public function addStyle($style){
//print_r($style);return;
$attributes = $style->attributes();
$key = $attributes['name'];
$this->arrayStyles["{$key}"] = $style; // here you can trate all parameter of style
}
public function getStyle($key){
if(isset($this->arrayStyles["{$key}"])){
return $this->arrayStyles["{$key}"];
}
}
public function applyStyle($key, &$reportElement){
$style = $this->getStyle($key);
if($style){
$attributes = $style->attributes();
foreach($attributes as $key => $value){
//ignore
if(!in_array($key,array('name'))){
//echo "{$key} - {$value}<br/>";
$reportElement[$key]=$value;
}
}
}
in TextField.php
` //print_r( $data["@attributes"]);
//exist style
if(isset($data->reportElement['style'])){
$name = $data->reportElement['style'];
$obj->applyStyle($name, $data->reportElement);
}`
from jasperphp.
that is, now when applying the style, you first need to check the conditional expression to choose which definition to apply the default or the conditional style...
from jasperphp.
this code help you to load and execute expression, i think it is same as printWhenExpression
Line 127 in c1a338d
from jasperphp.
get it here by modifying a little, so it checks and gets the style according to the conditional, it even accepts more than one conditional in the same style... I just can't say if this will affect the generator's performance... at the same here I haven't seen any effect, but everything can be improved.
from jasperphp.
modify for
`public function applyStyle($key, &$reportElement, $rowData){
$style = $this->getStyle($key);
if($style){
//default
$attributes = $style->attributes();
if(isset($style->conditionalStyle)){
//percore os styles
foreach($style->conditionalStyle as $styleNew){
$expression = $styleNew->conditionExpression;
//echo $expression;
$resultExpression = false;
$expression = $this->get_expression($expression, $rowData);
//echo 'if(' . $expression . '){$resultExpression=true;}<br/>';
eval('if(' . $expression . '){$resultExpression=true;}');
//echo $resultExpression."<br/>";
if($resultExpression){
//get definition style condicional
$attributCondicional= $styleNew->style->attributes();
$attributes = $attributCondicional;
break;
//var_dump($attributCondicional);
}
}
}
//change propriedades
foreach($attributes as $key => $value){
//ignore
if(!in_array($key,array('name'))){
//echo "{$key} - {$value}<br/>";
$reportElement[$key]=$value;
}
}
}
}`
from jasperphp.
great!!
from jasperphp.
about adding new variables I added in
Report.php
$obj->arrayVariable['COLUMN_COUNT'] = $rowIndex;//by gamadoleo
however to work the replace I had to make a small adjustment in the getValOfVariable method in the last one else
//by gamadoleo
if($ans==''){
return str_ireplace(array('$V{' . $variable . '}'), $val, $text);
}
return str_ireplace(array('$V{' . $variable . '}'), array($ans), $text);
from jasperphp.
the way I did the application of the style, it performs the conditional check on each TextField object, I don't know if I would be able to reduce this check, you who are more inside can analyze my function and see if you can improve the performance. but in the test here a 71 page report generates in less than 10s, but as I said everything can be improved.
from jasperphp.
ok, send a Pull Request with yours updates
from jasperphp.
add zebra style to cities sample
from jasperphp.
OK, just confirm about adding new variables for replication if I did something wrong? to not need to modify a getValOfVariable function
no details I added like this:
$obj->arrayVariable['COLUMN_COUNT'] = $rowIndex; // by gamma oil
however, tweak the getValOfVariable function
from jasperphp.
I will provide the example and send
ignore the aforementioned setting of Variable, actually the REPORT_COUNT works for me
from jasperphp.
Related Issues (20)
- salve, salve!
- JasperPHP + iReport 5.6 Error HOT 3
- Filter by Collection or Array HOT 4
- $P!{name} Parameters HOT 11
- Conditional print how to use? HOT 4
- Suport add element frame? HOT 4
- Does not respect the positioning HOT 3
- Band title with subreport, empty space HOT 1
- HEADER COLUMN REPEAT? HOT 3
- Rectangle does not put the border? HOT 5
- Header page does not repeat within subreport, second page.
- Support component table, let's implement it? HOT 1
- Se visualizan formulas en Campos con Expresiones Lógicas HOT 2
- Subreports HOT 2
- Fatal error with php 8.0 HOT 1
- How to install? HOT 1
- Grouping not working
- Feature suggestion: accept different types of dbData
- PHP 8.2 support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jasperphp.