onlywithnik Posted October 14, 2021 Posted October 14, 2021 I am trying to add conditional style programatically with existing reort. When I compilling with jasperdesign object it wont reflect any style in PDF. But same if i first write into JRXML and again load and compiling the it will work. ( see my commented lines those line works but why not with the same object)See below code it wont work:JasperDesign jasDes = new JasperDesign(); logger.info("Loading JRXML into Jasper Design: [" + rptPath + "]"); jasDes = JRXmlLoader.load(rptPath); JRDesignGroup jrDesignGroup = new JRDesignGroup(); jrDesignGroup.setName("pagebreak"); JRExpression jrExpression = new JRDesignExpression("$F{pgno}"); jrDesignGroup.setExpression(jrExpression); jrDesignGroup.setStartNewPage(true); jasDes.addGroup(jrDesignGroup); JRDesignStyle designStyle = new JRDesignStyle(); designStyle.setName("Table_TR"); designStyle.setMode(ModeEnum.OPAQUE); designStyle.setBackcolor(null); jasDes.addStyle(designStyle); jrExpression = new JRDesignExpression("$F{reclvl}.equals("B")"); JRDesignConditionalStyle conditionalStyle = new JRDesignConditionalStyle(); conditionalStyle.setBackcolor(Color.decode("#BD5553")); conditionalStyle.setMode(ModeEnum.OPAQUE); conditionalStyle.setConditionExpression(jrExpression); designStyle.addConditionalStyle(conditionalStyle);// String temp = JRXmlWriter.writeReport(jasDes, JRXmlTemplateWriter.DEFAULT_ENCODING);// JasperReport jasperReport = JasperCompileManager.compileReport(new ByteArrayInputStream(temp.getBytes()); JasperReport jasperReport = JasperCompileManager.compileReport(jasDes); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); JasperExportManager.exportReportToPdfFile(jasperPrint, exportPath);
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