Skip to main content
 首页 » 编程设计

c#之使用 C#(Windows 应用程序)创建 HTML 文档并在其中放置表格

2024年02月23日17powertoolsteam

我想创建一个 HTML 文档并使用 C# 创建表初始化。我不想使用 ASP 或任何类似的东西。我想通过使用 C# Windows 应用程序来执行此操作。

创建的文档不得使用MS Word或不依赖于任何其他应用程序并将其保存到任何文件夹(C:\)等。它完全独立于任何其他MS产品,可以在任何PC上运行

请您参考如下方法:

像这样:)

String exportdirectory = "c:"; 
StreamWriter sw; 
sw = File.CreateText(exportDirectory + "filename.html"); 
sw.WriteLine("<table>"); 
sw.WriteLine("<tr>"); 
sw.WriteLine("<td>"); 
sw.WriteLine("contents of table!"); 
sw.WriteLine("</td>"); 
sw.WriteLine("</tr>"); 
sw.WriteLine("</table>"); 
sw.Close();