microsoft.office.interop

https://social.msdn.microsoft.com/Forums/en-US/87e65b6a-f211-4b4a-9d42-a264dcf2a6f4/microsoftofficeinteropexceldll?forum=csharpgeneral

https://social.msdn.microsoft.com/Forums/vstudio/en-US/8bce17fb-eacd-4df3-8c10-bf8ae8a93c55/c-code-to-refresh-excel-data?forum=csharpgeneral

/*
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
*/
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
namespace ST_53932a75e92c44f086535fc017a56e6a.csproj
{
[System.AddIn.AddIn(“ScriptMain”, Version = “1.0”, Publisher = “”, Description = “”)]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
/*
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.
To reference a variable, call Dts.Variables[“MyCaseSensitiveVariableName”].Value;
To post a log entry, call Dts.Log(“This is my log text”, 999, null);
To fire an event, call Dts.Events.FireInformation(99, “test”, “hit the help message”, “”, 0, true);
To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add(“OLEDB”);
cm.ConnectionString = “Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;”;
Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

To open Help, press F1.
*/

public void Main()
{
// TODO: Add your code here
ExcelRefresh(@”C:\Documents and Settings\ST84879\Desktop\ROBERT_DATA_SET\TEST.xls”);
Dts.TaskResult = (int)ScriptResults.Success;
}

private void ExcelRefresh(string Filename)
{
object NullValue = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
excelApp.DisplayAlerts = false;
Microsoft.Office.Interop.Excel.Workbook Workbook = excelApp.Workbooks.Open(
Filename, NullValue, NullValue, NullValue, NullValue,
NullValue, NullValue, NullValue, NullValue, NullValue,
NullValue, NullValue, NullValue, NullValue, NullValue);
Workbook.RefreshAll();
System.Threading.Thread.Sleep(20000);

Workbook.Save();
Workbook.Close(false, Filename, null);
excelApp.Quit();
Workbook = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
}
}
}