I have been trying to get the following simple code work, but it raises and exception on using (var excelPackage = new ExcelPackage(finfo))
string filepath = Convert.ToString(Dts.Variables["User::FileFullPath"].Value);
if (File.Exists(filepath))
{
FileInfo finfo = new FileInfo(filepath);
MessageBox.Show(filepath);
try
{
using (var excelPackage = new ExcelPackage(finfo))
{
ExcelWorksheet ws = excelPackage.Workbook.Worksheets[0];
ws.Name = "Sheet1";
excelPackage.Save();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace, "Error", MessageBoxButtons.OK);
Dts.Events.FireError(1, "Check File Status", ex.StackTrace, "", 0);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
else
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
The error is :
By commenting out some lines I figured the error is on using (var excelPackage = new ExcelPackage(finfo))
line. Can someone tell what I am doing wrong here, or how to better get a more detailed exception?