単語の読み込みに関連する記事を読んでいますが、C#を使用して単語のドキュメント(Office 2007)を埋め込む必要があります。たとえば、[NAME]というラベルの付いたワードドキュメントを作成し、そのラベルをC#で使用して値を設定し、これをASP.NET MVC3コントローラで実行したいとします。何か案が?ASP.NET MVC3でC#を使用して単語テンプレートを埋め込む
2
A
答えて
3
Microsoftが提供するOpenXML SDKを使用してWord文書を操作できます。そして、ここにはnice article(実際には3つの記事のうちの3番目の記事です)といくつかの例があります。
0
あなたは次のように行うことができます: - Word文書テンプレート に「signets」を導入 - あなたのワードテンプレート のコピーで作業 - C#コードからsignets値を変更し、ファイルを保存または印刷します。アプリケーションで複数のドキュメントを扱う場合
は正しく単語プロセスを解放して気をつけてください:)質問から抽出された
0
OPのソリューション:
私が見つけた解決策はこれです:
static void Main(string[] args) { Console.WriteLine("Starting up Word template updater ..."); //get path to template and instance output string docTemplatePath = @"C:\Users\user\Desktop\Doc Offices XML\earth.docx"; string docOutputPath = @"C:\Users\user\Desktop\Doc Offices XML\earth_Instance.docx"; //create copy of template so that we don't overwrite it File.Copy(docTemplatePath, docOutputPath); Console.WriteLine("Created copy of template ..."); //stand up object that reads the Word doc package using (WordprocessingDocument doc = WordprocessingDocument.Open(docOutputPath, true)) { //create XML string matching custom XML part string newXml = "<root>" + "<Earth>Outer Space</Earth>" + "</root>"; MainDocumentPart main = doc.MainDocumentPart; main.DeleteParts<CustomXmlPart>(main.CustomXmlParts); //MainDocumentPart mainPart = doc.AddMainDocumentPart(); //add and write new XML part CustomXmlPart customXml = main.AddCustomXmlPart(CustomXmlPartType.CustomXml); using (StreamWriter ts = new StreamWriter(customXml.GetStream())) { ts.Write(newXml); } //closing WordprocessingDocument automatically saves the document } Console.WriteLine("Done"); Console.ReadLine(); }
関連する問題
- 1. cpとasp.netを使用してaspxページに単語文書を埋め込む
- 2. 抽出を埋め込む単語
- 3. Tensorflowモデルに埋め込み済みの単語を埋め込む
- 4. c、dec2binコンバーターを使用して配列を埋め込む
- 5. pybind11を使用してPythonをC++に埋め込むと、セグメンテーションフォールト
- 6. jQueryテンプレートを使用したYouTube動画の埋め込み - C#
- 7. ASP.NETを使用してZIPファイルを作成して埋め込む方法は?
- 8. 埋め込みリソースを使用してHttpHandlerにDLLを埋め込む
- 9. srec_catを使用してSレコードファイルを単語で埋める
- 10. マークアップ言語(C#)に画像を埋め込む方法は?
- 11. C言語でARMアセンブリを埋め込む
- 12. winformにms単語を埋め込む方法
- 13. 単語埋め込みの単語が欠けています
- 14. VBをasp.netに埋め込む方法
- 15. asp.netにSilverlightアプリケーションを埋め込む
- 16. コンパクトなフレームワークでc#を使用してテキストボックスコントロールにボタンを埋め込む方法
- 17. word2vecを使用してテストデータを含む単語埋め込みを行う必要がありますか?
- 18. ViewListを使用してImageListでListViewを埋め込む
- 19. アプリケーションをVBでADOBEを使用してフォームに埋め込む
- 20. VB6を使用してInfopath 2003フォームをプログラムで埋め込む
- 21. C#でWord文書を埋め込む
- 22. C#コードでビデオオブジェクトを埋め込む
- 23. PythonでCを埋め込む
- 24. Python GUIでC++プログラムを埋め込む
- 25. C#PDFファイルでtreeviewを埋め込む
- 26. 埋め込みyoutubeをc/gtkアプリケーションに埋め込む
- 27. JavaライブラリをC言語に埋め込む
- 28. 既に学習された単語埋め込みを使用して文字から単語埋め込みを学習する
- 29. 新しいcsprojを使用してPDBにC#ソースを埋め込む
- 30. jsonデータをフィールドに基づいてHTMLテンプレートに埋め込む
Cool。私はまた[このリンク](http://seroter.wordpress.com/2009/12/23/populating-word-2007-templates-through-open-xml/)が非常に有用であることを見出します。しかし、それでも[これ](http://stackoverflow.com/questions/9433332/open-xml-sdk-2-0)のために仕事を得ない:( –