Microsoft Excel - Exporting to an existing spreadsheet in excel

Asked By John Baldwin
27-Aug-10 09:25 AM
A new question for exporting to excel.

I am successfully able to export data from an sql table to excel by creating a new spreadsheet when executed. Is there any method by which I can export the data to an EXISTING spreadsheet with the same columns etc? So far I have not been able to figure it out.

Thanks
  Cika Pero replied to John Baldwin
02-Sep-10 04:41 AM
Hi,

you can do it easily with this Excel .NET component.

Here is an Excel C# sample code that exports DataTable to Excel with just one method call:
var ef = new ExcelFile();
ef.LoadXls("DataTable.xls");
 
// Find worksheet with same name as DataTable.
var ws = ef.Worksheets[dataTable.TableName];
 
// Append the data from DataTable to worksheet.
ws.InsertDataTable(dataTable, ws.GetUsedCellRange().Height, 0, false);
 
ef.SaveXls("DataTable.xls");
Create New Account
help
Microsoft.Office.Interop.Excel Hi, I am using Microsoft.Office.Interop.Excel to export the System.data Datatable values to the MS Excel. using Excel = Microsoft.Office.Interop.Excel; Excel.Application App = null; Excel._Workbook WB = null; Excel._Worksheet WS = null
How to get Excel.Worksheet in DataTable using C# Hi, I want to get the data from an excel worksheet to a data Table in c#. How I can do that using Microsoft.Office.Interop.Excel? This is my code snippets Microsoft.Office.Interop.Excel.Application ExcelObj = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(@"c: \ TestBook1
Export to Excel Button for Converting Datatable into excel sheet How to wtire a Export to Excel Function which will export a datatable content into excel sheet Here is the code which exports dataTable into Excel sheet. The code is in VB.Net Imports Microsoft.Office.Interop.Excel Private Sub ExportToExcel
error. . namespace contain defination confilct alias excel Hello sir, i am using the following code for export datatable into excel sheet the program shows following underline errors. . please solve and send me . . i try . . please help me Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop Excel.ApplicationClass(); Microsoft.Office.Interop.Excel.Workbook workbook = excel.Application.Workbooks.Add(true); / / true for object
how to store 3 tables in one excel sheet using c#.net hello sir i try following code 3 tables are stored as diffenrent excel sheet . . i want coding for 3 tables export in single excel sheet . . inside the excel create 3 worksheets. . in the 3 worksheet stores 3 tables i try this following code da1 = new SqlCeDataAdapter("select * from purchaseOrder", con); SqlCeDataAdapter da2 = new SqlCeDataAdapter("select * from newstock", con); DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); da.Fill(dt); da1.Fill(dt1); da2.Fill(dt2); Excel_FromDataTable(dt