Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 :

SQL
//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;
Posted
Updated 30-Sep-19 21:17pm

1 solution

Yes. Some problems...
May be create table and fill cells?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900