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

dispay values in detail band as TRANSPOSE


rbojja

Recommended Posts

Hi

I need to display my values in transpose manner in detail band (any other band) in transpose manner. ir

rows should be printed as columns.

 

Is this possible in Jasper. I use select stataments for my reports.The only way i think is to handle in jasper.

 

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Try this. I have used JasperPrint object to access the JRPrintText in your report output and change the location of the corresponding fields to do this.

 

private static JasperPrint transpose(JasperPrint jasperPrint)if (jasperPrint != null)if (pages != null && pages.size() > 0)null;null;null;null;int i = pages.size() - 1;boolean isFound = false;new ArrayList();while(i >= 0 && !isFound)if (elements != null && elements.size() > 0)int positionX = -1;int positionY = -1;while(it.hasNext() && !isFound)if (element instanceof JRPrintFrame)for (Object object : listElements) {out.println("object.getClass().getSimpleName()=" if (element instanceof JRPrintText)out.println(key + ((JRPrintText)element).getText());out.println("element.getY()+element.getWidth()=" + element.getY()+""+element.getWidth());out.println("element.getY()+element.getWidth()=" + element.getY()+""+element.getWidth());//jasperPrint.

 

//jasperPrint.addPage(0,jasperPrint.removePage(0));

 

 

}

}

 

 

}

return jasperPrint;

 

{

 

{

List pages = jasperPrint.getPages();

 

{

JRPrintPage page =

Collection elements =

Iterator it =

JRPrintElement element =

 

 

List modifiedElements =

 

{

page = (JRPrintPage)pages.get(i);

elements = page.getElements();

 

 

{

it = elements.iterator();

 

 

 

 

{

element = (JRPrintElement)it.next();

 

{

JRPrintFrame jrPrintFrame = (JRPrintFrame)element;

List listElements = jrPrintFrame.getElements();

 

System.

+ object.getClass().getSimpleName());

}

}

 

{

System.

System.

JRPrintText modifiedElement = ((JRPrintText)element);

positionX = positionX == -1 ? (modifiedElement.getX()-modifiedElement.getWidth()): positionX;

positionX+=modifiedElement.getWidth();

 

positionY = positionY == -1 ? (modifiedElement.getY()-modifiedElement.getHeight()): positionY;

 

modifiedElement.setX(positionX);

modifiedElement.setY(positionY);

modifiedElements.add(modifiedElement);

System.

 

}

modifiedElements.add(element);

}

}

 

i--;

 

}

page.setElements(modifiedElements);

 

Link to comment
Share on other sites

Hi

many thanks for your effort.Do you share me your code for better understanding.The xml file and the way your are handling the code in java class.

 

I thing going forward Jasper should add this feature in the iReport tool.

 

I am trying a solution of creating a plsql function for transpose to rows and call that function in select stmt of sql.This one i got in one of the forums of oracle.I am trying to fetch the output.

Link to comment
Share on other sites

This the query we can use to transpose rows to columns using a SELECT stmt.

 

select 'OBJECT_ID:'||object_id||' OBJECT_NAME:'||object_name

from mtv;

 

'OBJECT_ID:'||OBJECT_ID||'OBJECT_NAME:'||OBJECT_NAME

---------------------------------------------------------------------

OBJECT_ID:1 OBJECT_NAME:test

OBJECT_ID:2 OBJECT_NAME:testscn

OBJECT_ID:11 OBJECT_NAME:test

OBJECT_ID:12 OBJECT_NAME:testscn

OBJECT_ID:111 OBJECT_NAME:A

OBJECT_ID:112 OBJECT_NAME:D

 

 

Link to comment
Share on other sites

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...