Does it possible to expand single cell to span into multiple rows without affecting width of row.
是否可以扩展单个单元格以跨越多行而不影响行的宽度。
Suppose My PdfTable having 5 column and i want to expand 2nd rows 3rd column's cell till the 5th row without affecting any other cell into any other row
假设我的PdfTable有5列,我想扩展第2行第3列的单元格直到第5行,而不影响任何其他单元格到任何其他行
2 个解决方案
#1
0
See this example and PdfPCell.setRowspan(int) and PdfPCell.setColspan(int).
请参阅此示例和PdfPCell.setRowspan(int)和PdfPCell.setColspan(int)。
#2
0
Hi plese check with this .... code
嗨请检查这....代码
Document doc = new Document();
PdfWriter docWrite = null;
DecimalFormat df = new DecimalFormat("0.00");
DB.getPlayerName_OrderBy( TID1 , Match_ID);
try {
String path = Environment.getExternalStorageDirectory().getPath() + "/Cric";
Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);
File dir = new File(path);
if(!dir.exists()){dir.mkdirs();}
Log.d("PDFCreator", "PDF Path: " + path);
File file = new File(dir, "cric_sample.pdf");
FileOutputStream fOut = new FileOutputStream(file);
docWrite = PdfWriter.getInstance(doc, fOut);
doc.addTitle("Cricket Scord Card 2013 PDF");
doc.addCreationDate();
doc.open();
Paragraph p1 = new Paragraph(teamBatting + " Socre Card 2013 ");
float[] columnWidths = {5f, 5f, 2f, 2f,2f,2f,2f};
PdfPTable table = new PdfPTable(columnWidths);
table.setWidthPercentage(90f);
insertCell(table, "Player Names", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "Wicket Status", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "Runs", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "Balls", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "6's", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "4's", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "SR", Element.ALIGN_LEFT, 1, bfBold12);
table.setHeaderRows(1);
for(int x= 0; x<DatabaseHandler.Player_SD.size(); x++){
float SR;
if(DatabaseHandler.Player_SD.get(x).StrikerName == null)
{
break;
}
else
{
if(DatabaseHandler.Player_SD.get(x).Mrun !=0 &&DatabaseHandler.Player_SD.get(x).MBolls !=0)
{
SR= (((float)DatabaseHandler.Player_SD.get(x).Mrun/(float)DatabaseHandler.Player_SD.get(x).MBolls)) * 100;
}
else
{
SR =(float) 0.00;
}
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).StrikerName), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MOut), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).Mrun) , Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MBolls), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MSix), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MFour), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(String.format("%.1f",SR)), Element.ALIGN_LEFT, 1, bf12);
}
}
// p1.setAlignment(Paragraph.ALIGN_CENTER);
p1.add(table);
doc.add(p1);
} catch (DocumentException de) {
Log.e("PDFCreator", "DocumentException:" + de);
} catch (IOException e) {
Log.e("PDFCreator", "ioException:" + e);
}
finally
{
if(doc != null)
{
doc.close();
}
if(docWrite != null)
{
docWrite.close();
}
}
#1
0
See this example and PdfPCell.setRowspan(int) and PdfPCell.setColspan(int).
请参阅此示例和PdfPCell.setRowspan(int)和PdfPCell.setColspan(int)。
#2
0
Hi plese check with this .... code
嗨请检查这....代码
Document doc = new Document();
PdfWriter docWrite = null;
DecimalFormat df = new DecimalFormat("0.00");
DB.getPlayerName_OrderBy( TID1 , Match_ID);
try {
String path = Environment.getExternalStorageDirectory().getPath() + "/Cric";
Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);
File dir = new File(path);
if(!dir.exists()){dir.mkdirs();}
Log.d("PDFCreator", "PDF Path: " + path);
File file = new File(dir, "cric_sample.pdf");
FileOutputStream fOut = new FileOutputStream(file);
docWrite = PdfWriter.getInstance(doc, fOut);
doc.addTitle("Cricket Scord Card 2013 PDF");
doc.addCreationDate();
doc.open();
Paragraph p1 = new Paragraph(teamBatting + " Socre Card 2013 ");
float[] columnWidths = {5f, 5f, 2f, 2f,2f,2f,2f};
PdfPTable table = new PdfPTable(columnWidths);
table.setWidthPercentage(90f);
insertCell(table, "Player Names", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "Wicket Status", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "Runs", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "Balls", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "6's", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "4's", Element.ALIGN_LEFT, 1, bfBold12);
insertCell(table, "SR", Element.ALIGN_LEFT, 1, bfBold12);
table.setHeaderRows(1);
for(int x= 0; x<DatabaseHandler.Player_SD.size(); x++){
float SR;
if(DatabaseHandler.Player_SD.get(x).StrikerName == null)
{
break;
}
else
{
if(DatabaseHandler.Player_SD.get(x).Mrun !=0 &&DatabaseHandler.Player_SD.get(x).MBolls !=0)
{
SR= (((float)DatabaseHandler.Player_SD.get(x).Mrun/(float)DatabaseHandler.Player_SD.get(x).MBolls)) * 100;
}
else
{
SR =(float) 0.00;
}
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).StrikerName), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MOut), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).Mrun) , Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MBolls), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MSix), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(DatabaseHandler.Player_SD.get(x).MFour), Element.ALIGN_LEFT, 1, bf12);
insertCell(table, String.valueOf(String.format("%.1f",SR)), Element.ALIGN_LEFT, 1, bf12);
}
}
// p1.setAlignment(Paragraph.ALIGN_CENTER);
p1.add(table);
doc.add(p1);
} catch (DocumentException de) {
Log.e("PDFCreator", "DocumentException:" + de);
} catch (IOException e) {
Log.e("PDFCreator", "ioException:" + e);
}
finally
{
if(doc != null)
{
doc.close();
}
if(docWrite != null)
{
docWrite.close();
}
}