Word ドキュメントを読むために、Asp.Net と Interop.Word.dll を使用しています。私はこのようなものが必要です。単語にキーワードがあります。私はそれを見つけてテーブルに置き換えます。この処理をテキストに置き換えるようにしました。大丈夫です。今、文字列をテーブルに置き換えようとしています。こんなもの誰でも作れますか?前もって感謝します。
以下のようなコードを試します。
foreach (Microsoft.Office.Interop.Word.Range tmpRange in doc.StoryRanges)
{
object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
object findme = "##tablo1##";
//object replaceme = misyonval;
tmpRange.Application.Selection.Find.ClearFormatting();
tmpRange.Application.Selection.Find.Text = (string)findme;
tmpRange.Application.Selection.Find.Replacement.ClearFormatting();
object start = tmpRange.Start;
object end = tmpRange.End;
List<User> users = GetDummyUserData();
int noOfRows = users.Count + 1;
int noOfColumns = 5;
Microsoft.Office.Interop.Word.Table table = doc.Tables.Add(doc.Range(ref start, ref end), noOfRows, noOfColumns, ref nullobj, ref nullobj);
AddColumnHeaders(ref table);
for (int i = 1; i <= users.Count; i++)
{
table.Rows[i + 1].Cells[1].Range.Text = users[i - 1].FirstName;
table.Rows[i + 1].Cells[2].Range.Text = users[i - 1].LastName;
table.Rows[i + 1].Cells[3].Range.Text = users[i - 1].Email;
table.Rows[i + 1].Cells[4].Range.Text = users[i - 1].Address;
table.Rows[i + 1].Cells[5].Range.Text = users[i - 1].Pincode.ToString();
}
table.set_Style("Colorful List");
}