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;
Loading
Marvin ReidRank #1,963 · 746 reputationPosted May 11, 2022, 3:11 PM EDT
Leon DRank #851 · 2.6K reputationPosted May 12, 2022, 9:42 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts