- .doc が正しく作成されていません。単語の代わりに完全な html タグを使用して作成する
msワード文書の下のデータのように
<div id="ctl00_ContentPlaceHolder1_design" style="width:600px">
<table id="ctl00_ContentPlaceHolder1_rpt" border="0" width="600">
HTMLタグをプレーンコンテンツに変換する方法は?
aspx.cs
protected void btnMail_Click(object sender, EventArgs e)
{
Response.Clear();
try
{
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
design.RenderControl(htmlWrite);
string strBuilder = stringWrite.ToString();
string strPath = Request.PhysicalApplicationPath + "\\Temp\\WeeklyReport of " + Projname + ".doc";
if (File.Exists(strPath))
{
var counter = 1;
strPath = strPath.Replace(".doc", " (" + counter + ").doc");
while (File.Exists(strPath))
{
strPath = strPath.Replace("(" + counter + ").doc", "(" + (counter + 1) + ").doc");
counter++;
}
}
var doc = DocX.Create(strPath,DocumentTypes.Document);
doc.InsertParagraph(strBuilder);
doc.Save();
}
}