string html = "<html><head><title>44444444</title>"; html += @"<style type='text/css'> table { border-collapse: collapse; border: none; 200px; } td { border: solid #000 1px; } </style>"; html+="</head><body> <table><tr style='color:#777;background: #eaeaea;'><td>aaaa</td><td>bbbb</td>"; if (exportOptionCtl1.checkBox1.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox1.Tag + "</td>"; } if (exportOptionCtl1.checkBox2.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox2.Tag + "</td>"; } if (exportOptionCtl1.checkBox3.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox3.Tag + "</td>"; } if (exportOptionCtl1.checkBox4.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox4.Tag + "</td>"; } if (exportOptionCtl1.checkBox5.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox5.Tag + "</td>"; } html += "</tr>"; for (int i = 0; i < 109; i++) { html += "<td>aaaaa" +i + "</td>"; html += "<td>bbbbb" + i + "</td>"; if (exportOptionCtl1.checkBox1.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox1.Tag + "</td>"; } if (exportOptionCtl1.checkBox2.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox2.Tag + "</td>"; } if (exportOptionCtl1.checkBox3.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox3.Tag + "</td>"; } if (exportOptionCtl1.checkBox4.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox4.Tag + "</td>"; } if (exportOptionCtl1.checkBox5.IsChecked == true) { html += "<td>" + exportOptionCtl1.checkBox5.Tag + "</td>"; } html += "</tr> "; } html += "</table></body></html>"; StreamWriter w= File.CreateText("d:\wx.html"); w.Write(html); w.Flush(); w.Close();
<Grid x:Class="TestWpfApplication.ExportOptionCtl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="77" d:DesignWidth="417"> <Grid> <CheckBox Content="CheckBox1" Tag="ddd" Height="16" HorizontalAlignment="Left" Margin="6,6,0,0" Name="checkBox1" VerticalAlignment="Top" /> <CheckBox Content="CheckBox2" Tag="eee" Height="16" HorizontalAlignment="Left" Margin="91,6,0,0" Name="checkBox2" VerticalAlignment="Top" /> <CheckBox Content="CheckBox3" Tag="fff" Height="16" HorizontalAlignment="Left" Margin="167,6,0,0" Name="checkBox3" VerticalAlignment="Top" /> <CheckBox Content="CheckBox4" Tag="ggg" Height="16" HorizontalAlignment="Left" Margin="248,6,0,0" Name="checkBox4" VerticalAlignment="Top" /> <CheckBox Content="CheckBox5" Tag="hhh" Height="16" HorizontalAlignment="Left" Margin="6,37,0,0" Name="checkBox5" VerticalAlignment="Top" /> </Grid> </Grid>