我有2个网格,我需要导出为pdf ...
现在我可以导出..但是
我可以区分2个网格...意味着2个网格正在一个表中添加..
我需要2个网格之间的空间,以便我可以区分......
如何在2个网格之间保留空白空间....这是我的代码
gridview1:gvrpaList gridview1:rptisslst
protected void btnExportPDF_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvrpaList.AllowPaging = false;
//gvrpaList.DataBind();
gvrpaList.RenderControl(hw);
gvrpaList.HeaderRow.Style.Add("width", "15%");
gvrpaList.HeaderRow.Style.Add("font-size", "15px");
gvrpaList.Style.Add("text-decoration", "none");
gvrpaList.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
gvrpaList.Style.Add("font-size", "8px");
rptisslst.AllowPaging = false;
rptisslst.RenderControl(hw);
rptisslst.HeaderRow.Style.Add("width", "15%");
rptisslst.HeaderRow.Style.Add("font-size", "15px");
rptisslst.Style.Add("text-decoration", "none");
rptisslst.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
rptisslst.Style.Add("font-size", "8px");
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
byte[] byteArr = Encoding.ASCII.GetBytes(sw.ToString());
MemoryStream stream = new MemoryStream(byteArr);
StreamReader stre = new StreamReader(stream);
pdfDoc.Open();
htmlparser.Parse(stre);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
// verifies the control is rendered here
}
答案 0 :(得分:0)
您可以尝试添加换行符:
gvrpaList.RenderControl(hw);
hw.Write("<br />");
rptisslst.RenderControl(hw);