Excel Java report based on the template

Posted by: vin.sinha on 24 October 2020, 11:30 am EST

    • Post Options:
    • Link

    Posted 24 October 2020, 11:30 am EST - Updated 29 September 2022, 6:49 am EST

    Hi There, I am currently evaluating the grape city Java APIs for excel. Currently we have requirement to build dynamic report based on the backend dynamic data.

    When I tried the GC excel apis, its working fine for the single row configured row template. But when I have same object in more than 1 row , it’s not repeating the set of rows together as expected.

    I have attached here the screen shot of our basic template.

    Really appreciate if you can provide some insight and what exactly I am missing.

    //create a new workbook
           Workbook workbook = new Workbook();
           //Load template file from resource
           // InputStream templateFile = getResourceStream("Estonia_report_1.xlsx");
           File templateFile = new File("report_1.xlsx");
           workbook.open(new FileInputStream(templateFile));
           List<AdvertisingEventEE> advertisingEvents = new ArrayList<AdvertisingEventEE>();
           //#region Init Data
           AdvertisingEventEE record1 = new AdvertisingEventEE();
           record1.setActivityType("Activity 111");
           record1.setEventLocation("New York 111");
           record1.setEventName("Party 111");
           record1.setPurposeType("Confidential 111");
           //#region Init Data
           AdvertisingEventEE record2 = new AdvertisingEventEE();
           record2.setActivityType("Activity 222");
           record2.setEventLocation("New York 222");
           record2.setEventName("Party 222");
           record2.setPurposeType("Confidential 222");
    //Init template global settings
           workbook.getNames().add("TemplateOptions.KeepLineSize", "true");
    //Add data source
           workbook.addDataSource("advertisingEvent", advertisingEvents);
    //Invoke to process the template
    //save to an excel file
  • Posted 26 October 2020, 1:27 am EST


    We are working on your issue and we will get back to you soon on the same.



  • Posted 26 October 2020, 9:04 pm EST


    Can you please share your “Estonia_report_1.xlsx” template file with us so that we can replicate this issue further at our end and try to fix it? And also share which version of GcExcel JAVA are you using?



  • Posted 26 October 2020, 10:08 pm EST

    Thank you Reeva for your response. Here is the attached “Estonia_report_1.xlsx”. Idea is to repeat row from 5 to 7 for list of advertisingEvent object data.

    Please let me know if you would like further input from my side.

    Pls note, we are planning to have a customer demo this Friday Oct 30th, so appreciate if you can help on priority.

    Thanks again!

  • Posted 27 October 2020, 12:32 am EST


    We didn’t receive your attachment yet. Please zip the file once again and then attach.



  • Posted 28 October 2020, 8:27 am EST


    Attaching here the template again in xlsx and archive format. Appreciate your quick response.

  • Posted 28 October 2020, 10:07 pm EST

    Hi Reeva, any update on the above attached template?

  • Posted 28 October 2020, 11:52 pm EST


    I am unable to run your the sample with attached template.xlsx file and facing this exception: “Can’t find field or get method for ‘eventLocation’ of type ‘class AdvertisingEventEE’.”

    Please have a look at attached sample which isn’t working at our end. Request you to please modify the sample to replicate the issue and revert. We will look into this issue thereon.




  • Posted 29 October 2020, 11:31 am EST


    HI Reeva,

    PFA code base from my local which is generating the output as Report.xlsx from the sample java code, template xlsx file is “template.xlsx”. I have executed this code base in my local and working fine.

    As I mentioned above its repeating the for single row object. Challenge I am facing when I have same object and its attribute configured for multiple row. So inside the attached project template.xlsx example row 5 to 7 should repeat together.


  • Posted 30 October 2020, 12:08 am EST


    We are able to replicate the issue and hence we are escalating the same to the concerned team for the fix.

    Tracking id for your issue is #DOCXLS-3278

    We will update you as soon as we hear anything from our concerned team.



  • Posted 1 November 2020, 11:21 pm EST

    HI Reeva, is there any update on this ?

  • Posted 2 November 2020, 6:07 pm EST


    As per our understanding, you want to get a report like the one attached. Hence, you need to add a “Range” property for template in A6. Such as

    Aruande esitaja: {{advertisingEvent.eventLocation(R=A5:F7)}}			

    I have attached modified template and exported excel file. Please have a look. Let me know if you face any other issue.




Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels