wordpress hit counter
Re: Transform GridView in Open XML Table - .Net - Development Tools - OpenXML Developer

Re: Transform GridView in Open XML Table

Development Tools

Discussions about working with Open XML using a wide range of development tools

Transform GridView in Open XML Table

  • rated by 0 users
  • This post has 1 Reply |
  • 2 Followers
  • I have a GridView and I want to export it in Word document using open XML table


        var dt = FunctionThatReturnDataTable(id);                       

        var gd = new GridView               

                 {                           

                      DataSource = dt,                   

                      AutoGenerateColumns = true       

                  };


    I created a word document and inserted one paragraph inside, now i want to add my gridview below


     using (var myDoc = WordprocessingDocument.Create(@"c:test.doc",     WordprocessingDocumentType.Document))                 

      {           MainDocumentPart mainPart = myDoc.AddMainDocumentPart();               

            mainPart.Document = new Document();               

            var body = new Body();                     

      var p = new Paragraph(new ParagraphProperties(  Justification() { Val = JustificationValues.Center }), 

                                  new Run(new Text("Cartea Alfabetica")));     

                      body.Append(p);                       

    mainPart.Document.Append(body);                   

        mainPart.Document.Save();               

        }

  • Hi,

       You can look into this article. This converts gridview into excel. Similarly you can do for word.

Page 1 of 1 (2 items)