How to convert a , separated String to a table layout?

后端 未结 1 1726
耶瑟儿~
耶瑟儿~ 2021-01-24 09:47

I have a field with values:

CM45024,CM45025,CM45026

I want to separate this into multiple items using subreport. My jrxml source is:



        
1条回答
  •  失恋的感觉
    2021-01-24 10:21

    This is how it can be achieved using subreport, assuming that your $F{docIdNoGRN} contains the String "CM45024,CM45025,CM45026"

    1. Generate the data source that will be passed to the subreport

      
       
       
       
      
      

    As you can see I split(",") your field String getting an Array that is converted to List and then passed in a JRBeanCollectionDataSource

    1. Setup the subreport, the trick to reference our String is using _THIS as field value

    example: (your_subreport.jrxml):

    
    
        
        
            
                
                    
                    
                
                
                    
                    
                
            
        
    
    

    I have added the $V{REPORT_COUNT} to achieve the numbers (1,2,3) .

    The output will be

    1 CM45024
    2 CM45025
    3 CM45026

    Note: You can also use the jr:table component to achieve this if you like to avoid generating a subreport (just define the table datasource as above)

    0 讨论(0)
提交回复
热议问题