Hello,

I would like to have a table like this :

http://old.nabble.com/file/p26890992/report%2Btable.jpg 

but i don't know how i can do this. I have many problem with border and
pdfptable in pdfptable. This is my code :

PdfPTable table = new PdfPTable(2);
                table.setHeaderRows(1);
                table.setSpacingBefore(15);
                table.setSpacingAfter(15);
                PdfPCell cellHeaderCompetence = new PdfPCell(new 
Phrase("Competence"));
                table.addCell(cellHeaderCompetence);
                PdfPTable tableHeader = new PdfPTable(2);
                tableHeader.addCell("Score");
                tableHeader.addCell("Courses associate");
                tableHeader.getDefaultCell().setBorder(Rectangle.NO_BORDER);
                table.addCell(tableHeader);
                List<IndividualTrainingPlan> itp = itpService
                                
.getAllIndividualTrainingPlanByTraineeId(traineeId);
                if (itp.size() == 0) {
                        PdfPCell cellNoValue = new PdfPCell(new Phrase(
                                        "No Training History"));
                        cellNoValue.setColspan(3);
                        table.addCell(cellNoValue);
                }
                int competenceOldId = -1;
                for (IndividualTrainingPlan individualTrainingPlan : itp) {
                        PdfPCell cellCompetenceValue = new PdfPCell();
                        Competence c = competenceService
                                        
.getCompetence(individualTrainingPlan.getCompetenceId());
                        if (competenceOldId != c.getId() || competenceOldId == 
-1) {
                                competenceOldId = c.getId();
                                /* Competence */
                                cellCompetenceValue.addElement(new 
Phrase(c.getName()));
                                table.addCell(cellCompetenceValue);
                                List<IndividualTrainingPlan> 
listItpByCompetence = itpService
                                                
.getIndividualTrainingPlanByCompetenceId(c.getId());
                                
table.addCell(getTableScoreCourse(listItpByCompetence));
                        }
                }
                return table;
        }
        public static PdfPTable getTableScoreCourse(
                        List<IndividualTrainingPlan> listItpByCompetence) {
                PdfPTable table = new PdfPTable(2);
                table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
                int count = 0;
                for (IndividualTrainingPlan individualTrainingPlan : 
listItpByCompetence)
{
                        count++;
                        String date = new
SimpleDateFormat("yyyy-MM-dd").format(individualTrainingPlan.getLastAssessment().getDate());
                        String value = String.valueOf(individualTrainingPlan
                                        .getLastAssessment().getScore())
                                        + " ("
                                        + date + ")";
                        table.addCell(value);
                        StringBuilder s = new StringBuilder();
                        List<TrainingPlanItem> planItems = tpiService
                                        
.getListTrainingPlanItemByItp(individualTrainingPlan
                                                        .getId());
                        for (TrainingPlanItem trainingPlanItem : planItems) {
                                CourseUnit course = courseService
                                                
.getCourseUnit(trainingPlanItem.getCourseUnitID());
                                s.append(course.getName());
                                s.append("\n");
                        }
                        table.addCell(s.toString());
                }
                return table;
        }

and the result is :

http://old.nabble.com/file/p26890992/report%2Btable%2B2.jpg 

thanks you
-- 
View this message in context: 
http://old.nabble.com/problem-table-in-table-tp26890992p26890992.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to