O
OldeEnglishD
Guest
Local: Windows 7
Server: 2012 R2
Main Program:
===========================================================
static void Main(string[] args)
{
string strFileDatabaseNamePath = "", strFileDatabaseName = "", strPathDBTo = "", strPath = "",
strPathSpreadSheetsTo = "", strFileNameOnly = "";
string[] arrFiles = null;
FileInfo[] files = null;
int intResult = 0, intPos = 0;
LogError.Log("Parameter 0 = ", args[0], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("Parameter 1 = ", args[1], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("Parameter 2 = ", args[2], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("Parameter 3 = ", args[3], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
strFileDatabaseNamePath = args[0].Replace("\r\n", "");
LogError.Log("strFileDatabaseNamePath = ", strFileDatabaseNamePath, "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
strPathDBTo = args[1].Replace("\r\n", "");
intPos = strFileDatabaseNamePath.LastIndexOf("\\");
strFileDatabaseName = strFileDatabaseNamePath.Substring(intPos + 1, strFileDatabaseNamePath.Length - intPos - 1);
strPathSpreadSheetsTo = args[2].Replace("\r\n", "");
arrFiles = Directory.GetFiles(strPathSpreadSheetsTo, "*.xlsx");
if (arrFiles.Count() == 0)
{
LogError.Log("No Spreadsheets to Process!", "Exe is Running", "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Environment.Exit(0);
}
strPath = strPathSpreadSheetsTo.Replace("*.xlsx", "");
//*** Take the master database (spreadsheet) and import it into the MySql database table for ease of processing
intResult = FileToProcess.ReadRowsInSSheet(ref strFileDatabaseName, strPathDBTo);
===========================================================
FilesToProcess Module:
==========================================================
public static int ReadRowsInSSheet(ref string strFileName, string strAppPath)
{
string strShipToPart = "", strSuppPart = "", strDesc = "", strHomeLoc = "", strCarLine = "", strPartFam = "", strCarDesig = "", strModelYr = "",
strSuppName = "", strCountryOfOrigin = "", strShipTo1 = "", strSuppCode = "", strProgram = "", strRetPartNum = "", strStdPack = "", strTareWgt = "",
strUnits = "", strContHgt = "", strUnitsINorMM = "", strWgtPerPiece = "", strUnits2 = "", strStdPackPerCont = "", strPartsPerPallet = "", strDock = "",
strLF = "", strReserveLF = "", strFordSuppCode = "", strShipTo2 = "", strShipTo2Name = "";
int intRow = 2, intRet = 0;
Microsoft.Office.Interop.Excel.Application oXLFrom = null;
Database2 db = new Database2();
_Workbook oWBFrom = null;
oXLFrom = new Microsoft.Office.Interop.Excel.Application();
oXLFrom.Interactive = false;
oXLFrom.DisplayAlerts = false;
LogError.Log("strAppPath = ", strAppPath, "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("strFileName = ", strFileName, "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
try
{
//Master database (spreadsheet)
//******** BLOWS UP HERE ***************************
oWBFrom = oXLFrom.Workbooks.Open(strAppPath + "\\" + strFileName);
}
==========================================================
Logfile:
========================================================
...16:10:22: Parameter 0 = C:\Global Label Formats\Label Data Sets\Ford LAP Mix-Master Label Dataset.xls
...16:10:22: Parameter 1 = C:\Programs\EDI_Part_Update_DB_Console
...16:10:22: Parameter 2 = \\Bemivas01\Public\IT\EDIFiles\862Test
...16:10:22: Parameter 3 = C:\Programs\EDI_Part_Update_DB_Console\ExcelCollection
...16:10:22: strFileDatabaseNamePath = C:\Global Label Formats\Label Data Sets\Ford LAP Mix-Master Label Dataset.xls
...16:10:23: strAppPath = C:\Programs\EDI_Part_Update_DB_Console
...16:10:23: strFileName = Ford LAP Mix-Master Label Dataset.xls
...16:10:23: FileToProcess.ReadRowsInSSheet.Open Method: Exception from HRESULT: 0x800A03EC
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at Ford_EDI_Parts_Update.FileToProcess.ReadRowsInSSheet(String& strFileName, String strAppPath)
Found in Open Excel File
...16:10:23: Processing Complete! Exe is Running
========================================================
Can open Excel worksheet locally but not on the server!
Continue reading...
Server: 2012 R2
Main Program:
===========================================================
static void Main(string[] args)
{
string strFileDatabaseNamePath = "", strFileDatabaseName = "", strPathDBTo = "", strPath = "",
strPathSpreadSheetsTo = "", strFileNameOnly = "";
string[] arrFiles = null;
FileInfo[] files = null;
int intResult = 0, intPos = 0;
LogError.Log("Parameter 0 = ", args[0], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("Parameter 1 = ", args[1], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("Parameter 2 = ", args[2], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("Parameter 3 = ", args[3], "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
strFileDatabaseNamePath = args[0].Replace("\r\n", "");
LogError.Log("strFileDatabaseNamePath = ", strFileDatabaseNamePath, "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
strPathDBTo = args[1].Replace("\r\n", "");
intPos = strFileDatabaseNamePath.LastIndexOf("\\");
strFileDatabaseName = strFileDatabaseNamePath.Substring(intPos + 1, strFileDatabaseNamePath.Length - intPos - 1);
strPathSpreadSheetsTo = args[2].Replace("\r\n", "");
arrFiles = Directory.GetFiles(strPathSpreadSheetsTo, "*.xlsx");
if (arrFiles.Count() == 0)
{
LogError.Log("No Spreadsheets to Process!", "Exe is Running", "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Environment.Exit(0);
}
strPath = strPathSpreadSheetsTo.Replace("*.xlsx", "");
//*** Take the master database (spreadsheet) and import it into the MySql database table for ease of processing
intResult = FileToProcess.ReadRowsInSSheet(ref strFileDatabaseName, strPathDBTo);
===========================================================
FilesToProcess Module:
==========================================================
public static int ReadRowsInSSheet(ref string strFileName, string strAppPath)
{
string strShipToPart = "", strSuppPart = "", strDesc = "", strHomeLoc = "", strCarLine = "", strPartFam = "", strCarDesig = "", strModelYr = "",
strSuppName = "", strCountryOfOrigin = "", strShipTo1 = "", strSuppCode = "", strProgram = "", strRetPartNum = "", strStdPack = "", strTareWgt = "",
strUnits = "", strContHgt = "", strUnitsINorMM = "", strWgtPerPiece = "", strUnits2 = "", strStdPackPerCont = "", strPartsPerPallet = "", strDock = "",
strLF = "", strReserveLF = "", strFordSuppCode = "", strShipTo2 = "", strShipTo2Name = "";
int intRow = 2, intRet = 0;
Microsoft.Office.Interop.Excel.Application oXLFrom = null;
Database2 db = new Database2();
_Workbook oWBFrom = null;
oXLFrom = new Microsoft.Office.Interop.Excel.Application();
oXLFrom.Interactive = false;
oXLFrom.DisplayAlerts = false;
LogError.Log("strAppPath = ", strAppPath, "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
LogError.Log("strFileName = ", strFileName, "C:\\Programs\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
try
{
//Master database (spreadsheet)
//******** BLOWS UP HERE ***************************
oWBFrom = oXLFrom.Workbooks.Open(strAppPath + "\\" + strFileName);
}
==========================================================
Logfile:
========================================================
...16:10:22: Parameter 0 = C:\Global Label Formats\Label Data Sets\Ford LAP Mix-Master Label Dataset.xls
...16:10:22: Parameter 1 = C:\Programs\EDI_Part_Update_DB_Console
...16:10:22: Parameter 2 = \\Bemivas01\Public\IT\EDIFiles\862Test
...16:10:22: Parameter 3 = C:\Programs\EDI_Part_Update_DB_Console\ExcelCollection
...16:10:22: strFileDatabaseNamePath = C:\Global Label Formats\Label Data Sets\Ford LAP Mix-Master Label Dataset.xls
...16:10:23: strAppPath = C:\Programs\EDI_Part_Update_DB_Console
...16:10:23: strFileName = Ford LAP Mix-Master Label Dataset.xls
...16:10:23: FileToProcess.ReadRowsInSSheet.Open Method: Exception from HRESULT: 0x800A03EC
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at Ford_EDI_Parts_Update.FileToProcess.ReadRowsInSSheet(String& strFileName, String strAppPath)
Found in Open Excel File
...16:10:23: Processing Complete! Exe is Running
========================================================
Can open Excel worksheet locally but not on the server!
Continue reading...