Posted 24 October 2020, 8:30 pm EST - Updated 29 September 2022, 3:49 pm 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.setAmountLC(111.34);
record1.setEventLocation("New York 111");
record1.setEventName("Party 111");
record1.setLocalCurrency("USD");
record1.setPurposeType("Confidential 111");
advertisingEvents.add(record1);
//#region Init Data
AdvertisingEventEE record2 = new AdvertisingEventEE();
record2.setActivityType("Activity 222");
record2.setAmountLC(222.34);
record2.setEventLocation("New York 222");
record2.setEventName("Party 222");
record2.setLocalCurrency("Ruppee");
record2.setPurposeType("Confidential 222");
advertisingEvents.add(record2);
//#endregion
//Init template global settings
workbook.getNames().add("TemplateOptions.KeepLineSize", "true");
//Add data source
workbook.addDataSource("advertisingEvent", advertisingEvents);
//Invoke to process the template
workbook.processTemplate();
//save to an excel file
workbook.save("Report.xlsx");