Jump to content
We've recently updated our Privacy Statement, available here ×

Export to Excel with property expression SUM on multiple pages


dott

Recommended Posts

I create invoice (like document) (Title, Column header, Detail1,Column header) with ireport.

I export to excel with property expression to have excel formula instead of integer numbers only for value of item and for sum of values. Detail1 is the item list which has: product art.number (String)/ product name (String) / price (Integer)/ quantity (Interger) / value (price*quantity) in each Detail1 row.

To calculate value for an item (in column F in my case), I use property expression (for first item to get the value = D14(price)*E14(quantity)) (above this are cells that contain title and column header) 

<textField pattern="#,##0 EUR">
                <reportElement x="400" y="0" width="140" height="20" uuid="sdsa">
                    <propertyExpression name="net.sf.jasperreports.export.xls.formula"><![CDATA["=D"+new Integer($V{REPORT_COUNT}.intValue()+13)+"*E"+new Integer($V{REPORT_COUNT}.intValue()+13)+""]]></propertyExpression>
                </reportElement>

I used below solution for that

https://community.jaspersoft.com/questions/526602/static-and-dynamic-excel-formula-ireport-314

This works for 1 page, but if I have many items in Detail1 that fits for more than 1 page, then with page break it will include column header and column footer for each page and which takes up 8 rows between the items. These are not counted in the above property expression. So on second page where the item starts at row 46 the value is only D38*E38 and not D46*E46. 

The SumOfValues variable also works only for 1 page. If there are multiple pages, the sum of values are not correctly calculated with property expression like this:

<textField pattern="#,##0 EUR" isBlankWhenNull="true">
                <reportElement x="400" y="10" width="140" height="20" uuid="sfd">
                    <propertyExpression name="net.sf.jasperreports.export.xls.formula"><![CDATA["=SUM(F14:F"+($V{COLUMN_COUNT}+13)+")"]]></propertyExpression>
                </reportElement>

Where F14 is the first cell to start the sum until the last item, which is :F"+($V{COLUMN_COUNT}+13)+". But this expression does not handle column header and footer that adds rows to pages. 

Help is appreciated.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...