我運行下面的代碼,如果我一步直通代碼它顯示我的價值,但是當它到達變量未顯示價值
if (Directory.Exists(folderPath))
FNAME沒有在FOLDERPATH被顯示。它只是舉例說明。
"\\\\Delta\\" + fName + "_Monday\\"
有人可以告訴我我應該更新以使其正常工作嗎?
public static void OpenExcelWorkbook()
{
fName = new string[4] { "Mike", "Joe", "Hickney", "Rich", };
folderPaths = new string[7]
{
"\\\\Delta\\" + fName + "_Monday\\",
"\\\\Delta\\" + fName + "_Tuesday\\",
"\\\\Delta\\" + fName + "_Wednesday\\",
"\\\\Delta\\" + fName + "_Thursday\\",
"\\\\Delta\\" + fName + "_Friday\\",
"\\\\Delta\\" + fName + "_Saturday\\",
"\\\\Delta\\" + fName + "_Sunday\\",
};
fileNames = new string[4]
{
fName + "_generaldaily_file.xlsx",
fName + "_employeeDaily_cumulative.xls",
fName + "_generaldaily_file.xlsx",
fName + "_employeeDaily_cumulative.xls",
};
Excel.Workbook wb = null;
try
{
for (int q = fName.GetLowerBound(0); q <= fName.GetUpperBound(0); q++)
{
foreach (string fileName in fileNames)
{
foreach (string folderPath in folderPaths)
{
if (Directory.Exists(folderPath))
{
foreach (string filePath in Directory.GetFiles(folderPath))
{
string temp = Path.GetFileName(filePath).ToLower();
if (temp == fileName.ToLower())
{
oWB = (Excel._Workbook)(oXL.Workbooks.Open(folderPath + fileName));
oWB = oXL.ActiveWorkbook;
oWB.RefreshAll();
//Calling method to save workbook here
}
}
}
}
}
}
}
catch { }
}
fname在哪裏申報?我在這裏看不到代碼。 – ThunderGr
我會補充說,肯定給我一分鐘 – MasterOfStupidQuestions
'它只顯示例如。 「\\\\ Delta \\」+ fName +「_Monday \\」' 你是什麼意思?任何字符串如何顯示? – Tarec