I want to rename excel sheetname without using Microsoft.Office.Interop.Excel bec Ms Office is not installed on my server .
public void Main()
{
// TODO: Add your code here
var path = Dts.Variables["User::FilePath"].Value.ToString();
//Declare and initilize variables
string fileFullPath = path.ToString();
//Create Excel Connection
string ConStr;
string HDR;
HDR = "YES";
ConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileFullPath + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";
OleDbConnection cnn = new OleDbConnection(ConStr);
//Get Sheet Name
cnn.Open();
DataTable dtSheet = cnn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string sheetname;
sheetname = "";
//Only read data from provided SheetNumber
dtSheet.Rows[0]["TABLE_NAME"]=Dts.Variables["User::WorksheetName"].Value.ToString();
cnn.Close();
Dts.TaskResult = (int)ScriptResults.Success;
}
what i need to modify in my code to update the worksheet name with the value imported by the variable 'WorksheetName'.