我想使用OpenXML WordProcessing製作表格。我想格式化單元格內的字體。這是我的代碼格式字體內部表OpenXML C#
MainDocumentPart mainDocumentPart = doc.AddMainDocumentPart();
mainDocumentPart.Document = new Document();
Body body = mainDocumentPart.Document.AppendChild(new Body());
RunProperties runHeader = new RunProperties();
RunFonts runFont = new RunFonts();
runFont.Ascii = "Lucida Sans";
runHeader.Append(runFont);
runHeader.Append(new Bold());
runHeader.Append(new FontSize() { Val = "16" });
//// Create a new table
Table tbl = new Table();
tr = new TableRow();
tc = new TableCell();
Paragraph paraHeader = new Paragraph();
Text heading_text = new Text("Company Name");
runHeader.Append(heading_text);
paraHeader.Append(runHeader);
tc.Append(paraHeader);
tr.Append(tc);
tbl.Append(tr);
body.AppendChild(tbl);
但是當我在Microsoft Word上打開時,出現錯誤。它說文件有內容問題
你檢查此鏈接: http://stackoverflow.com/questions/7956630/how-can-i-change-the-font-open-xml – Bryan 2013-02-28 17:24:26