Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9280377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:51:25+00:00 2026-06-18T17:51:25+00:00

I really need help with this.. I can’t find any example on the internet

  • 0

I really need help with this.. I can’t find any example on the internet
I am using DevExpress GridView I need to send it to excel and I’m getting problems to loop to every cell and column because DevExpress contains different methods then the DataGridView

that’s the code that i’m trying to write.. I really Appreciate your help

    public class Form1 : System.Windows.Forms.Form
    {
    Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();

    string FirstName = "First Name";
    string FatherName = "Father Name";
    string LastName = "Last Name";
    }
    public Form1()
    {
        ExcelApp.Application.Workbooks.Add(Type.Missing);
        ExcelApp.Columns.ColumnWidth = 20;
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();

        //
        // TODO: Add any constructor code after InitializeComponent call
        //
    }
    private void simpleButton1_Click(object sender, System.EventArgs e)
    {
        try
        {
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\\Users\\pc\\Documents\\Emp.xlsx;Extended Properties=\"Excel 12.0;HDR=Yes\"";

            con.Open();
            DataTable dtSchema;
            dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
            OleDbCommand Command = new OleDbCommand ("select * FROM [" + dtSchema.Rows[0]["TABLE_NAME"].ToString() + "]", con);
            OleDbDataAdapter da = new OleDbDataAdapter(Command);
            DataSet ds = new DataSet ();
            da.Fill(ds);
            dataGrid1.DataSource = ds.Tables[0];
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    private void ExportBtn_Click(object sender, System.EventArgs e)
    {
        for (int i = 1; i < gridView3.Columns.Count + 1; i++)
        {
            //ExcelApp.Cells[1, i] = gridView3.Columns[i].HeaderStyleName;

        }
        for (int i = 0; i< gridView3.RowCount - 1; i++)
        {
            for (int j = 0; j < gridView3.Columns.Count; j++)
            {
                ExcelApp.Cells[i + 2, j + 1] = gridView3.Columns[j].ToString();
            }
        }
        ExcelApp.ActiveWorkbook.SaveCopyAs("C:\\Users\\pc\\Emp.xlsx");
        ExcelApp.ActiveWorkbook.Saved = true;
        ExcelApp.Quit();
    }

My problem is in the Export button the click event.. There’s no such thing as Row()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:51:26+00:00Added an answer on June 18, 2026 at 5:51 pm

    To know various export methods of XtraGrid, go through Export Methods and Settings

    Use GridControl.ExportToXls(String) Method

    Example code snippet:

    private void mnuExportTable_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
    {
        using (SaveFileDialog saveDialog = new SaveFileDialog())
        {
            saveDialog.Filter = "Excel (2003)(.xls)|*.xls|Excel (2010) (.xlsx)|*.xlsx |RichText File (.rtf)|*.rtf |Pdf File (.pdf)|*.pdf |Html File (.html)|*.html";
            if (saveDialog.ShowDialog() != DialogResult.Cancel)
            {
                string exportFilePath = saveDialog.FileName;
                string fileExtenstion = new FileInfo(exportFilePath).Extension;
                
                switch (fileExtenstion)
                {
                    case ".xls":
                        gridControl.ExportToXls(exportFilePath);
                        break;
                    case ".xlsx":
                        gridControl.ExportToXlsx(exportFilePath);
                        break;
                    case ".rtf":
                        gridControl.ExportToRtf(exportFilePath);
                        break;
                    case ".pdf":
                        gridControl.ExportToPdf(exportFilePath);
                        break;
                    case ".html":
                        gridControl.ExportToHtml(exportFilePath);
                        break;
                    case ".mht":
                        gridControl.ExportToMht(exportFilePath);
                        break;
                    default:
                        break;
                }
    
                if (File.Exists(exportFilePath))
                {
                   try
                   {
                       //Try to open the file and let windows decide how to open it.
                       System.Diagnostics.Process.Start(exportFilePath);
                    }
                    catch
                    {
                        String msg = "The file could not be opened." + Environment.NewLine + Environment.NewLine + "Path: " + exportFilePath;
                        MessageBox.Show(msg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                 }
                 else
                 {
                     String msg = "The file could not be saved." + Environment.NewLine + Environment.NewLine + "Path: " + exportFilePath;
                     MessageBox.Show(msg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
            }
        }
    }
    

    Reference:
    Exporting Several XtraGrid Controls to a Single Excel File

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i really need some help on this. I searched the internet but couldn't find
I really need help this time - Joomla 2.5 and latest K2. I'm using
sorry if you'll find this question stupid, but I really need help. Here's some
I really need help getting this query right. I can't share actual table and
I really really need help in this. I am using node.js with mongodb and
I really need help with this last part of my program. I need to
I Really need help in this ... I'm building an application where I need
I really need help on this one. I am having a simple login form
Sorry to bother again, but I really need help transforming this Python2 code into
I really need your help for this. I am relatively new to programming and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.