My datas in PDF consists of 20 rows. I'm using do while loop for getting this 20 values from database. I trying to set rowspan for the last set of datas, which am unable to do so, as the last values are getting broken. Below is my codings...
PdfPTable tablel = new PdfPTable(3);
tablel.setWidthPercentage(100);
//Header
PdfPCell cell1 = new PdfPCell(new Phrase("S No"));
PdfPCell cell2 = new PdfPCell(new Phrase("Parameter"));
PdfPCell cell3 = new PdfPCell(new Phrase("Unit"));
tablel.addCell(cell1);
tablel.addCell(cell2);
tablel.addCell(cell3);
//Datas
Cursor c= dbs.query("kiosk_trn_tsoilparameter", new String[]{"soilparam_gid","soilparam_soil_gid","soil_parameter","soil_uom","soil_results"
}, "soilparam_soil_gid" + "=? COLLATE NOCASE",
new String[]{id}, null, null, null, null);
int i = 1;
if (c.moveToFirst()) {
do {
//to get increment values of i
String group = String.valueOf(i);
cell1 = new PdfPCell(new Phrase(group));
tablel.addCell(cell1);
String selectQuery1 = "SELECT * FROM core_mst_tmaster....";
Cursor cursor1 = dbs.rawQuery(selectQuery1, null);
if(cursor1.moveToNext())
{
String machine = cursor1.getString(0);
cell1 = new PdfPCell(new Phrase(machine));
tablel.addCell(cell1);
}
String selectQuery2 = "SELECT * FROM core_mst_tmaster ....";
Cursor cursor2 = dbs.rawQuery(selectQuery3, null);
if(cursor2.moveToNext())
{
String machine = cursor2.getString(0);
cell2 = new PdfPCell(new Phrase(machine));
tablel.addCell(cell2);
}
String selectQuery3 = "SELECT * FROM core_mst_tmaster.... ";
Cursor cursor3 = dbs.rawQuery(selectQuery3, null);
if(cursor3.moveToNext())
{
String machine = cursor3.getString(0);
cell3 = new PdfPCell(new Phrase(machine));
cell3.setRowspan(3);
tablel.addCell(cell3);
}
i++;
while (c.moveToNext());
}
document.add(tablel);
I have also tried to put if loop to get first set of values and for the remaining set of values I assigned empty values and tried to assigned rowspan for the remaining set of values, but still it is not working.
Below is the coding...
//to get first set of values
if(i==1){
String machine = cursor3.getString(0);
cell3 = new PdfPCell(new Phrase(machine));
tablel.addCell(cell3);
}else{
// to get remaining values
String machine = cursor3.getString(0);
cell3 = new PdfPCell(new Phrase(machine));
cell3.setRowspan(3);
tablel.addCell(cell3);
}
```
Any codings I missed out...please help me out...