本文介绍了如何使用C#导出PDF中的标签数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我已经在标签上创建了一个报告,我想用pdf导出它按钮点击它的代码是什么??? Plz帮我... 谢谢... I have create a report on label and i want export it in pdf on button click what's the code for that???Plz help me ...Thanks...推荐答案 con = clsSql.getconnection; try { lblExcept.Text = null; if (Convert.ToInt32(con.State) < 1) { con.Open(); } frmDt = txtFromDate.Text.Trim(); endDt = txtEndDate.Text.Trim(); dd = frmDt.Substring(0, 2); mm = frmDt.Substring(3, 2); yy = frmDt.Substring(6, 4); frmDt = mm + "/" + dd + "/" + yy; dd = endDt.Substring(0, 2); mm = endDt.Substring(3, 2); yy = endDt.Substring(6, 4); endDt = mm + "/" + dd + "/" + yy; lblExcept.Text = null; lblTab.Text = null; query = @"select did,Sno,convert(varchar(11),Date,106) as Date,REGION,CLIENTSNAME,ShortAddress,CATEGORY,Local_Corporate_Client,PERSON,MOB_PH_No,EMAIL,AGENCY,HOTCLINT,TARGET,Visitby,Remarks from DSR where Date between '" + frmDt + @"' and '" + endDt + "' "; cmd = new SqlCommand(query, con); dr = cmd.ExecuteReader(); lblTab.Text = null; if (dr.HasRows) { lblTab.Text += @"<table id='data-grid' class='alternate' border='0' cellpadding='0' cellspacing='0'>"; lblTab.Text += @"<tr>"; lblTab.Text += @"<th width='50' align='left'>SlNo</th>"; lblTab.Text += @"<th width='110' align='left'>Date</th>"; lblTab.Text += @"<th width='110' align='left'>REGION</th>"; lblTab.Text += @"<th width='110' align='left'>CLIENTSNAME</th>"; lblTab.Text += @"<th width='110' align='left'>ShortAddress</th>"; lblTab.Text += @"<th width='110' align='left'>CATEGORY</th>"; lblTab.Text += @"<th width='110' align='left'>Local_Corporate_Client</th>"; lblTab.Text += @"<th width='110' align='left'>PERSON</th>"; lblTab.Text += @"<th width='50' align='left'>MOB_PH_No</th>"; lblTab.Text += @"<th width='50' align='left'>EMAIL</th>"; lblTab.Text += @"<th width='50' align='left'>AGENCY</th>"; lblTab.Text += @"<th width='50' align='left'>HOTCLINT</th>"; lblTab.Text += @"<th width='50' align='left'>TARGET</th>"; lblTab.Text += @"<th width='50' align='left'>Visitby</th>"; lblTab.Text += @"<th width='50' align='left'>Remarks</th>"; lblTab.Text += @"</tr>"; NetAmt = 0; while (dr.Read()) { i += 1; lblTab.Text += @"<tr>"; lblTab.Text += @"<td valign='top'>" + i + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Date"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["REGION"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["CLIENTSNAME"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["ShortAddress"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["CATEGORY"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Local_Corporate_Client"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["PERSON"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["MOB_PH_No"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["EMAIL"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["AGENCY"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["HOTCLINT"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["TARGET"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Visitby"]) + "</td>"; lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Remarks"]) + "</td>"; lblTab.Text += @"</tr>"; } lblTab.Text += @"</table>"; } else { lblTab.Text = "Data Not Found Please Check Date..."; } if (dr.IsClosed == false) { dr.Close(); } } catch (Exception ex) { lblExcept.Text = ex.Message.ToString(); } finally { if (Convert.ToInt32(con.State) >= 1) { con.Close(); } } i want export result in pdf...i want export result in pdf... 这篇关于如何使用C#导出PDF中的标签数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 04:38