일부 데이터는 DataGridview (Winform)에 표시됩니다. datagridview에 표시된 테이블을 비슷한 형식 (행, 열 등)으로 메일로 보내기 요구 사항이 있습니다. 내가 할 수있는 가장 쉬운 방법은 무엇입니까? 열 머리글을 사용하여 html 테이블로 변환하고 열 너비를 유지하는 방법.DataGridView C# WinForm의 데이터를 html로
0
A
답변
1
빠른 구글 검색이 나왔고 : How to send DataGridView contents by email. DGV를 HTML 테이블로 변환하고 메일을 보내는 방법을 다룹니다.
2
발생할 수있는 프레임 워크 수준 변환이 있는지 알 수 없습니다. 그러나 그리드 행과 셀을 반복하고 너비가있는 HTML로 다시 만드는 것은 매우 간단합니다.
불완전 함과 간단한 실수는 용서해주십시오. 기본 생각은 여기에 있습니다.
StringBuilder sb = new SringBuilder();
sb.AppendLine("<table>");
sb.AppendLine(" <tr>");
foreach(DataGridViewColumn column in grid.Columns)
{
sb.AppendLine(" <td>" + column.HeaderText + "</td>");
}
sb.AppendLine(" </tr>");
foreach(DataGridViewRow row in grid.Rows)
{
sb.AppendLine(" <tr>");
foreach(DataGridViewCell cell in row.Cells)
{
sb.AppendLine(" <td width=\"" + cell.Width + "px\">" + cell.Value + "</td>");
}
sb.AppendLine(" </tr>");
}
sb.AppendLine("</table>");
1
당신이 그렇게하지 않으면 당신이 웹
에이를 찾을 것입니다 검색하면 내 생각은 ...
Do the following
1. Create a stringbuilder, wrap it with htmlTextWriter
2. Create a htmltable, add a header row,
3. Iterate through the gridheaders and add cells, write the width in attributes, write other stuff like font, fontsize, forecolor, backcolor etc if you want
4. Next iterate through the grid rows, add a row each time to table, add cells to row for each grid cells
5. Call the render method passing the html writer
6. Take the string builder out and you have a html table layout output.
관련 문제
- 1. datagridview in C#
- 2. xml 데이터를 테이블 열에 datagridview 컨트롤에 표시합니다. C# winforms
- 3. datagridview 데이터를 텍스트 상자
- 4. Datagridview : 데이터를 다시로드하는 방법?
- 5. xml 데이터를 html로 표시
- 6. DataGridView C#
- 7. DataGridView in C#
- 8. winform의 Datagridview에서 배경색을 칠하지 않음
- 9. Winform의 DataGridViewComboBoxColumn에서 사용자 선택 유지
- 10. C# datagridview datatable
- 11. ViewState를 WinForm의
- 12. C# DataGridView AutoSizeRowsMode 문제
- 13. datagridview datetimepicker C# help
- 14. 데이터를 기반으로하는 Datagridview 행 서식
- 15. 표 형식의 데이터를 HTML로 묶기
- 16. html로 데이터베이스 데이터를 인쇄하십시오. 테이블
- 17. winform의 DataRepeater 컨트롤에 데이터 추가
- 18. C# datagridview gridlines
- 19. C# DataGridView AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
- 20. 배열에 C# datagridview 열
- 21. C# bound Datagridview
- 22. Argument OutOfRangeException C# DataGridView
- 23. C# DataGridView - 투명한 이미지
- 24. C# DataGridView 정리합니다.
- 25. C++에서 PHP/HTML로 보내기
- 26. C# Datagridview - TextColumn을 ComboBoxColumn으로 변환
- 27. C# 개체를 Html로 렌더링
- 28. WinForm의 SizeToContent와 동급입니까?
- 29. Winform의 WPF 이벤트
- 30. DataGridView 내 하위 DataGridView
참고 : http://stackoverflow.com/questions/16008477/export-datagridview-to-html-page –