Hello there,
Can someone please suggest a suitable data structure for the below problem:
I have row headers and column headers..and the intersecting cells have their respective values.
Note: The col names and row names should also be stored.
I'm extracting the data from an excel sheet using Apache POI and SAX parser. During extraction, I need to output the data in the above format.
What I have tried:
Sample code :
createPDF.addTableContent(incident, "Open", 1);
createPDF.addTableContent(incident, pe.getOValue("Open&Assigned to Resolver"), 2);
createPDF.addTableContent(incident, pe.getOValue("Open&Business Action Required"), 1);
createPDF.addTableContent(incident, pe.getOValue("Open&Monitoring"), 2);
createPDF.addTableContent(incident, pe.getOValue("Open&Reopened"), 1);
createPDF.addTableContent(incident, pe.getOValue("Open&Requestor Action required"), 2);
createPDF.addTableContent(incident, pe.getOValue("Open&RFC Implementation"), 1);
createPDF.addTableContent(incident, pe.getOValue("Open&Work In Progress"), 2);
createPDF.addTableContent(incident, Integer.toString(pe.getTotalCount("Open")), 1);
createPDF.addTableContent(incident, "In Progress", 1);
createPDF.addTableContent(incident, pe.getOValue("In Progress&Assigned to Resolver"),2);
createPDF.addTableContent(incident, pe.getOValue("In Progress&Business Action Required"),1);
createPDF.addTableContent(incident, pe.getOValue("In Progress&Monitoring"), 2);
createPDF.addTableContent(incident, pe.getOValue("In Progress&Reopened"), 1);
createPDF.addTableContent(incident, pe.getOValue("In Progress&Requestor Action required"), 2);
createPDF.addTableContent(incident, pe.getOValue("In Progress&RFC Implementation"), 1);
createPDF.addTableContent(incident, pe.getOValue("In Progress&Work In Progress"), 2);
createPDF.addTableContent(incident, Integer.toString(pe.getTotalCount("In Progress")), 1);
createPDF.addTableContent(incident, "Pending", 1);
createPDF.addTableContent(incident, pe.getOValue("Pending&Assigned to Resolver"), 2);
createPDF.addTableContent(incident, pe.getOValue("Pending&Business Action Required"), 1);
createPDF.addTableContent(incident, pe.getOValue("Pending&Monitoring"), 2);
createPDF.addTableContent(incident, pe.getOValue("Pending&Reopened"), 1);
createPDF.addTableContent(incident, pe.getOValue("Pending&Requestor Action required"), 2);
createPDF.addTableContent(incident, pe.getOValue("Pending&RFC Implementation"), 1);
createPDF.addTableContent(incident, pe.getOValue("Pending&Work In Progress"), 2);
createPDF.addTableContent(incident, Integer.toString(pe.getTotalCount("Pending")), 1);
The current method I've tried is concatenating the col and row name using "&" and storing its value in a hash map.
For example : A&E=1, B&B=6
Problem I'm facing currently
when ever I want to extract a value from the hashmap, I have to use string processing. If I want to get the count of col A, I have to iterate and split the col and row names and add the values. If I have to get the count for row E, again I have to do the same thing.
Is there any efficient way of achieving it.
Sharing the output from my current solution. Data is extracted from the excel and should be displayed to the user as below :
https://pasteboard.co/I1AwMsl.png[
^]
Thanks,
Balaji