public bool LoadXLS(string strFileName) { fileName = strFileName; string nakedFileName = System.IO.Path.GetFileName(strFileName); Excel.Application app = new Excel.Application(); app.Workbooks.Open(strFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); Excel.Workbook workBook = app.Workbooks[1]; workBook.Activate(); Excel.Worksheet sheet = (Excel.Worksheet)workBook.Sheets[1]; pgbCurrent.Minimum = 2; pgbCurrent.Maximum = sheet.UsedRange.Rows.Count; pgbCurrent.Value = 2; int rowCont = sheet.UsedRange.Rows.Count; MH4Global.lbXLS.Text = "Loading and Converting... : " + nakedFileName; MH4Global.lbXLS.Update(); // 일반 퀘스트 문서인지, 스폐셜 퀘스트 문서인지 파악한다. bool bIsSpecialXLS = MH4Global.IsSpecialQuestXLS(strFileName); Thread[] trdList = new Thread[MH4Global.THREAD_MAX]; for (int i = 0; i < MH4Global.THREAD_MAX; ++i) { ThreadTask task = new ThreadTask(dataBase, i + 2, rowCont + 1, MH4Global.THREAD_MAX, sheet.UsedRange); if (bIsSpecialXLS) { trdList[i] = new Thread(task.LoadXLSSpecial); } else { trdList[i] = new Thread(task.LoadXLS); } trdList[i].IsBackground = true; trdList[i].Start(); } for (int i = 0; i < MH4Global.THREAD_MAX; ++i) { trdList[i].Join(); } app.ActiveWorkbook.Close(false, Missing.Value, Missing.Value); return(true); }
// 이미 로딩되었으면 True, 스레드로 넘기면 false를 반환 public static bool OpenTextAllData(string strFileName, LocalizeSource localSource) { if (localSource == LocalizeSource.LOCAL_KOREAN || localSource == LocalizeSource.LOCAL_JAPANESE) { if (textDataMap != null && textDataMap.Count > 0) { return(true); } textDataMap = new Dictionary <string, TextAllData>(); dicConvertTag = new Dictionary <string, string>(); dicConvertJapan = new Dictionary <string, string>(); currMap = textDataMap; } // 일본어 태그 변경은 필요없다. //else if(localSource == LocalizeSource.LOCAL_JAPANESE) //{ // if (textDataMapJap != null && textDataMapJap.Count > 0) // return true; // textDataMapJap = new Dictionary<string, TextAllData>(); // dicConvertJapan = new Dictionary<string, string>(); // currMap = textDataMapJap; //} if (appTextAllData == null) { textAllDataFileName = strFileName; appTextAllData = new Excel.Application(); appTextAllData.Workbooks.Open(strFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } Excel.Workbook workBook = appTextAllData.Workbooks[1]; workBook.Activate(); Excel.Worksheet sheet = (Excel.Worksheet)workBook.Sheets[LocalizeSource.LOCAL_KOREAN]; usedRange = sheet.UsedRange; int rowCnt = usedRange.Rows.Count; sheet = (Excel.Worksheet)workBook.Sheets[LocalizeSource.LOCAL_JAPANESE]; usedRangeJap = sheet.UsedRange; MH4Global.pgbXLS.Minimum = 2; MH4Global.pgbXLS.Maximum = rowCnt; MH4Global.pgbXLS.Value = 2; MH4Global.lbXLS.Text = "Load Text All Table..."; MH4Global.lbXLS.Update(); Thread[] trdList = new Thread[MH4Global.THREAD_MAX]; for (int i = 0; i < MH4Global.THREAD_MAX; ++i) { ThreadTask task = new ThreadTask(i + 2, rowCnt + 1, MH4Global.THREAD_MAX); trdList[i] = new Thread(task.InsertTextAllData); trdList[i].IsBackground = true; trdList[i].Start(); } return(false); }