Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jun 17, 2016 12:28 pm

hi
i use spire.office for convert gridview data to pdf
i got data in pdf file but not in fix format so i try this code
Code: Select all
System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("<html>");
        sb.AppendFormat("<body>");
       sb.AppendFormat("<table>");
        sb.AppendFormat("<tr>");
        foreach (DataGridViewColumn column in dgv.Columns)
        {
          sb.AppendFormat("<th>");
           sb.AppendFormat(column.Name);
           sb.AppendFormat("</th>");
        }
        sb.AppendFormat("</tr>");
        sb.AppendFormat("<tr>");
        foreach (DataGridViewRow row in dgv.Rows)
        {

            foreach (DataGridViewCell cell in row.Cells)
            {
                sb.AppendFormat("<td>");
                sb.Append(cell.Value);
                sb.AppendFormat("</td>");
            }
        }
        sb.AppendFormat("</tr>");
        sb.AppendFormat("</table>");
        sb.AppendFormat("</body>");
        sb.Append("</html>");
         return sb.ToString();

but i got output data with tags

kumbhanibhavesh
 
Posts: 1
Joined: Thu May 26, 2016 4:00 am

Mon Jun 20, 2016 6:05 am

Hi,

Thanks for your posting.
Please use LoadFromHTML method to convert html code to PDF.
Here is a tutorial.
http://www.e-iceblue.com/Tutorials/Spir ... -in-C.html

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Wed Jun 22, 2016 6:03 am

Hi,

Did LoadFromHTML method resolve your issue?
Thanks for your feedback in advance.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF

cron