I currently have created a c# executable that will update my server based on the values in and xlsx (which is maintained by someone else on a network drive). I want to set up the executable to run on our server as a scheduled task, however the server does not have Office installed (nor will it ever have Office installed).<br/><br/>Is there anyway to modify the c# code such that the xlsx is updated prior doing all the other steps?<br/><br/>At the moment my refresh method looks as follows, and Id like to change it if possible to do the same function without having to call excel.<br/><br/>
<pre>private static void DataRefresh(String excelFilePath)
{
Excel.Application ExcelObj;
try
{
ExcelObj = new Excel.Application();
ExcelObj.DisplayAlerts = false;
ExcelObj.Visible = false;
Excel.Workbook eBook = ExcelObj.Workbooks.Open(excelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// background query should be set in the Excel spreadsheet to "False"
// connectionType = xlconnectiontypeXMLMap cannot programmatically change the background query option
eBook.RefreshAll();
eBook.RefreshAll();
eBook.Save();
ExcelObj.Workbooks.Close();
ExcelObj.Quit();
NAR(eBook);
NAR(ExcelObj);
}
catch (Exception e)
{
Console.WriteLine("Could not update Excel! ");
}
}[/code]
View the full article
<pre>private static void DataRefresh(String excelFilePath)
{
Excel.Application ExcelObj;
try
{
ExcelObj = new Excel.Application();
ExcelObj.DisplayAlerts = false;
ExcelObj.Visible = false;
Excel.Workbook eBook = ExcelObj.Workbooks.Open(excelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// background query should be set in the Excel spreadsheet to "False"
// connectionType = xlconnectiontypeXMLMap cannot programmatically change the background query option
eBook.RefreshAll();
eBook.RefreshAll();
eBook.Save();
ExcelObj.Workbooks.Close();
ExcelObj.Quit();
NAR(eBook);
NAR(ExcelObj);
}
catch (Exception e)
{
Console.WriteLine("Could not update Excel! ");
}
}[/code]
View the full article