Solved

Export GridView Data to Excel

Posted on 2014-02-12
1
513 Views
Last Modified: 2014-02-18
Dear All Experts,

I need to export Gridview Data to excel by JavaScript code with supporting Arabic language

in ASP.net
0
Comment
Question by:Asrar Azmi
1 Comment
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 39855825
you can start with below code. you need to modify as per your requirement.

  function XlsExport()
 {
        try {
            var i;
            var j;
            var mycell;
            var tableID = "tblGridView";

            var objXLS = new ActiveXObject("Excel.Application");
            var objWB = objXLS.Workbooks.Add();
            var objWS = objWB.ActiveSheet;

            for (i = 0; i < document.getElementById('<%= tblAuditReport.ClientID %>').rows.length; i++) {
                for (j = 0; j < document.getElementById('<%= tblAuditReport.ClientID %>').rows(i).cells.length; j++) {
                    mycell = document.getElementById('<%= tblAuditReport.ClientID %>').rows(i).cells(j);
                    objWS.Cells(i + 1, j + 1).Value = mycell.innerText;
                }
            }

            //objWS.Range("A1", "L1").Font.Bold = true;

            objWS.Range("A1", "Z1").EntireColumn.AutoFit();

            objXL.Visible = true;

        }
        catch (err)
       {

       }

    }

Open in new window

0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hbo knew my windows software 4 63
JSON  parse help 7 40
Finding the IIS version 5 22
transition to visual .net from vb6 5 41
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question