Transfering Data to Excel in C#
The technique that is most frequently used to transfer data to an Excel workbook is Automation. With Automation, you can call methods and properties that are specific to Excel tasks. Automation gives you the greatest flexibility for specifying the location of your data in the workbook, formatting the workbook, and making various settings at run-time.
With Automation, you can use several techniques to transfer your data:
| • | Transfer data cell by cell. |
| • | Transfer data in an array to a range of cells. |
| • | Transfer data in an ADO recordset to a range of cells by using the CopyFromRecordset method. |
| • | Create a QueryTable object on an Excel worksheet that contains the result of a query on an ODBC or OLEDB data source. |
| • | Transfer data to the clipboard, and then paste the clipboard contents into an Excel worksheet. |
To transfer your data without Automation, you can use the following approaches:
| • | Transfer your data to a tab-delimited or comma-delimited text file that Excel can later parse into cells on a worksheet. |
| • | Transfer your data to a worksheet by using ADO.NET. |
| • | Transfer XML data to Excel (version 2002 and 2003) to provide data that is formatted and arranged into rows and columns. |


