引用:https://blog.youkuaiyun.com/sinat_35165183/article/details/54743612
StreamWriter sw = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath("~/temp.html"), false, Encoding.Default);
sw.Write("<html><head></head><body>");
sw.Write(ar1.note);
sw.Write("</body></html>");
sw.Close();
string strs = "<html><head></head><body>" + ar1.note + "</body></html>";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(strs);
Section currentSection = builder.CurrentSection;
Aspose.Words.PageSetup pageSetup = currentSection.PageSetup;
pageSetup.HeaderDistance = 50;
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
//builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
//builder.Underline = Underline.Single;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
// Set font properties for header text.
//builder.Font.Name = "仿宋_GB2312";
//builder.RowFormat.Alignment = RowAlignment.Center;
builder.Font.Bold = true;
builder.Font.Size = 18;
// Specify header title for the first page.
//if (headflag == 1)
//{
builder.Write(article.HeaderPrimary);
//}
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Write(article.FooterPrimary);
string path = Server.MapPath("~/word/" + article.company);
if (!System.IO.Directory.Exists(path)) {
System.IO.Directory.CreateDirectory(path);
}
doc.Save(path +"/" + article.company + t + ".doc");
object oFalse = false;
object oTrue = true;
object oMissing = System.Reflection.Missing.Value;
t++;
=============================================================
字体颜色:
Aspose.Words.Font font = builder.Font;
font.Size = 16;
font.Bold = true;
font.Color = Color.Blue;
======================================
设置标题
//builder.RowFormat.Alignment = RowAlignment.Center;
//builder.CellFormat.Borders.LineStyle = LineStyle.Single;
//builder.InsertHtml("<h1>1、分析数据</h1>");
//builder.InsertHtml("<h2>1.1 数据一</h2>");
//builder.InsertHtml("<h2>1.2 数据二</h2>");
//builder.InsertHtml("<h3>1.2.1 计算分析</h3>");