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