Page 1 of 2

expression in picture dose`t work

Posted: Mon Jan 25, 2021 1:26 am
by simon ren
hello,I user reports.java to render my reports.
i have a picture component in my report,when i use "datacolumn" in my picture it works well.
but when i use "expression " in my picture it does`t works.

Does the picture component support expressions??

The screenshot is as follows

here is the "datacolumn" it works
datacolumn
datacolumn
datacolumn.png (133.51 KiB) Viewed 4703 times
here is the "expression " it not works
expression
expression
expression.png (151.03 KiB) Viewed 4703 times
here is the results
result.png
result.png (72.71 KiB) Viewed 4703 times

Re: expression in picture dose`t work

Posted: Mon Jan 25, 2021 9:41 pm
by Lech Kulikowski
Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank yuo.

Re: expression in picture dose`t work

Posted: Tue Jan 26, 2021 1:33 am
by simon ren
Lech Kulikowski wrote: Mon Jan 25, 2021 9:41 pm Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank yuo.
here is the mrt and test data
PrintFormat.mrt
(12.81 KiB) Downloaded 299 times
PrintData - 副本.json
(223.35 KiB) Downloaded 264 times

Re: expression in picture dose`t work

Posted: Wed Jan 27, 2021 9:57 pm
by HighAley
Hello,

The expression should return an Image object.
But inside the column we see the Base64 string.
You should use the Data Column in this case.

Thank you.

Re: expression in picture dose`t work

Posted: Thu Jan 28, 2021 2:52 am
by simon ren
HighAley wrote: Wed Jan 27, 2021 9:57 pm Hello,

The expression should return an Image object.
But inside the column we see the Base64 string.
You should use the Data Column in this case.

Thank you.
thanks,
i tried use Data Column is ok,but In my business scenario,i need use expression to do some conditional judgment。
you mean that if i use expression like '{cmp2.pic}',then the column ‘pic’ in my datasource must a java Image Objcet not a string?

Re: expression in picture dose`t work

Posted: Mon Feb 01, 2021 8:38 pm
by Lech Kulikowski
Hello,

Yes. Or you can use the Data Column in this case.

Thank you.

Re: expression in picture dose`t work

Posted: Sun Feb 07, 2021 3:02 am
by simon ren
Lech Kulikowski wrote: Mon Feb 01, 2021 8:38 pm Hello,

Yes. Or you can use the Data Column in this case.

Thank you.
thanks, i tried set my picture column as a BufferedImage,but it doesn`t work.
like this.

Code: Select all

byte[] bytes1 = new BASE64Decoder().decodeBuffer(ds.tables.get(11).getRows().get(0).getValue("Pic").toString());
ByteArrayInputStream bais = new ByteArrayInputStream(bytes1);
BufferedImage bi1 = ImageIO.read(bais);
ds.tables.get(11).getRows().get(0).setValue("Pic",bi1);

Re: expression in picture dose`t work

Posted: Sat Feb 20, 2021 9:42 am
by simon ren
HighAley wrote: Wed Jan 27, 2021 9:57 pm Hello,

The expression should return an Image object.
But inside the column we see the Base64 string.
You should use the Data Column in this case.

Thank you.
thanks, i tried set my picture column as a BufferedImage,but it doesn`t work.
like this.

Code: Select all

byte[] bytes1 = new BASE64Decoder().decodeBuffer(ds.tables.get(11).getRows().get(0).getValue("Pic").toString());
ByteArrayInputStream bais = new ByteArrayInputStream(bytes1);
BufferedImage bi1 = ImageIO.read(bais);
ds.tables.get(11).getRows().get(0).setValue("Pic",bi1);

Re: expression in picture dose`t work

Posted: Tue Feb 23, 2021 12:22 pm
by Vadim
Hello.

ds.tables.get(11).getRows().get(0).setValue("Pic",bi1); is data column, so you need string base64 image here.

Re: expression in picture dose`t work

Posted: Wed Feb 24, 2021 1:10 am
by simon ren
Vadim wrote: Tue Feb 23, 2021 12:22 pm Hello.

ds.tables.get(11).getRows().get(0).setValue("Pic",bi1); is data column, so you need string base64 image here.
thanks ,but in my business, we need use Expression,Can you tell me how can i use Expression in Image Component? can you give me some demo?