//作業の詳細
PdfPTable tabl2 = new PdfPTable(7);
// tabl2.TotalWidth = 350f;
//tabl2.LockedWidth = true;
//tabl2.HorizontalAlignment = 0;
tabl2.SpacingBefore = 10f;
bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
times = new Font(bfTimes, 12f, Font.UNDERLINE);
para = new Paragraph("Working Details:", times);
para.Alignment = Element.ALIGN_LEFT;
doc.Add(para);
cell.Colspan = 3;
cell.Rowspan = 2;
cell.HorizontalAlignment = 0;
cell.BorderColor = new BaseColor(0, 0, 0);
//tabl2.AddCell(new Phrase("Sr.No.", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Working Place", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Date Of Joining", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Institute Name", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Year", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Duration", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Post held at last", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl2.AddCell(new Phrase("Area of Work", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
string connects = @"Data Source=BOPSERVER;Initial Catalog=Project;Integrated Security=True";
using (SqlConnection cn = new SqlConnection(connects))
{
string query = "select * from Working_det where Fid='" + va+"'";
SqlCommand cmd = new SqlCommand(query, cn);
try
{
cn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
tabl2.AddCell(new Phrase(sdr[1].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl2.AddCell(new Phrase(Convert.ToDateTime(sdr[2]).ToShortDateString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl2.AddCell(new Phrase(sdr[3].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl2.AddCell(new Phrase(sdr[4].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl2.AddCell(new Phrase(sdr[5].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl2.AddCell(new Phrase(sdr[6].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl2.AddCell(new Phrase(sdr[7].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
cell.Rowspan = 2;
cell.Colspan = 2;
tabl2.AddCell(cell);
tabl2.SpacingAfter = 30f;
doc.Add(tabl2);
//Membership Details
PdfPTable tabl3 = new PdfPTable(4);
tabl3.SpacingBefore = 10f;
bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
times = new Font(bfTimes, 12f, Font.UNDERLINE);
para = new Paragraph("Membership Details:", times);
para.Alignment = Element.ALIGN_LEFT;
doc.Add(para);
cell.Colspan = 3;
cell.Rowspan = 2;
cell.HorizontalAlignment = 0;
cell.BorderColor = new BaseColor(0, 0, 0);
tabl3.AddCell(new Phrase("Membership Number", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl3.AddCell(new Phrase("Type of Membership", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl3.AddCell(new Phrase("Validity", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
tabl3.AddCell(new Phrase("Remarks", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
string connect = @"Data Source=BOPSERVER;Initial Catalog=Project;Integrated Security=True";
using (SqlConnection cn = new SqlConnection(connect))
{
string query = "select * from Membership_det where Fid=='" + va + "'";
SqlCommand cmd = new SqlCommand(query, cn);
try
{
cn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
tabl3.AddCell(new Phrase(sdr[1].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl3.AddCell(new Phrase(sdr[2].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl3.AddCell(new Phrase(sdr[3].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
tabl3.AddCell(new Phrase(sdr[4].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
cell.Rowspan = 2;
cell.Colspan = 2;
tabl3.AddCell(cell);
tabl3.SpacingAfter = 30f;
doc.Add(tabl3);
上記のコードは、pdf でデータを表示することを示しています。作業内容に表示されました
コードに変更はありませんが、データは取得されません..これに関するヘルプを提案してください..