0

I have the following code which exports to a new Excel but I want to export to an existing one:

 //      Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
    //        Workbook thodoris = xla.Workbooks.Add(XlSheetType.xlWorksheet);
    //        Worksheet mike = (Worksheet)xla.ActiveSheet;

    //        xla.Visible = true;

    //     for (int i=1;i<dataGridView1.ColumnCount+1;i++)
    //    {
    //        xla.Cells[1, i] = dataGridView1.Columns[i - 1].HeaderText;

    //    }

    //     for (int i = 0; i < dataGridView1.RowCount; i++)
    //         {
    //             for (int j = 0; j < dataGridView1.ColumnCount; j++)
    //             {

    //                     xla.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString();


    //         }

    //       }

How can I do that?

pnuts
  • 58,317
  • 11
  • 87
  • 139
  • Perhaps this link can help: [Get instance of Excel application with C# by Handle](http://stackoverflow.com/questions/1118735/get-instance-of-excel-application-with-c-sharp-by-handle) – MacroMarc Oct 11 '15 at 18:37
  • thak you but I am tryivg to build somethivg from scratch – user3142452 Oct 11 '15 at 18:40

0 Answers0