janki chavda

janki chavda

  • NA
  • 1
  • 1.5k

How to insert multiple image in word document using Interop

Apr 16 2014 4:47 AM
I have a list of data to insert in Word document.I am using Microsoft Word Object Library dll for data insert in Word document.my data look like first column is image and other column is name,address etc..One record should be display in only one page in created document.when I insert data in word document using below code at that time all image display first and then other data display .But I need to display record wise data look like image,name,address etc...
My C# code is
//Get report Data list List<Art> ListData = oArts.LoadListData(); Paragraph para = document.Content.Paragraphs.Add(ref missing); para.Range.InsertParagraphBefore(); string imgPath; for (int i = 0; i < ListData.Count; i++) { string path = Server.MapPath("~/ArtImages/") + ListData[i].ArtID; imgPath = path + @"\" + ListData[i].ImageMaster.ImagePath; InlineShape map = document.InlineShapes.AddPicture(imgPath, ref missing, ref missing, ref missing); map.Height = 350; map.Width = 350; para.Range.Text = "Name : " + ListData[i].Name + Environment.NewLine; para.Range.Text = "Address : " + ListData[i].Address + Environment.NewLine; para.Range.InsertParagraphAfter(); object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak; para.Range.InsertBreak(ref oPageBreak); } //Save the document object filename = "@C:\\ArtDetails.doc"; document.Close(ref missing, ref missing, ref missing); document = null; winword.Quit(ref missing, ref missing, ref missing); winword = null;

Answers (2)