rbojja Posted October 1, 2008 Share Posted October 1, 2008 HiI need to display my values in transpose manner in detail band (any other band) in transpose manner. irrows 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 More sharing options...
shrije Posted October 3, 2008 Share Posted October 3, 2008 I am looking for the same thing. planning to use Generic element to do this. Not sure if it will help. Will let you know once done. Link to comment Share on other sites More sharing options...
shrije Posted October 6, 2008 Share Posted October 6, 2008 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 More sharing options...
shrije Posted October 6, 2008 Share Posted October 6, 2008 Please find the corresponding output. Link to comment Share on other sites More sharing options...
rbojja Posted October 7, 2008 Author Share Posted October 7, 2008 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 More sharing options...
shrije Posted October 7, 2008 Share Posted October 7, 2008 I have already added the code in the trail above. Let me know if you face issues. Link to comment Share on other sites More sharing options...
rbojja Posted October 9, 2008 Author Share Posted October 9, 2008 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now