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); }
// 일본어 테이블에서 태그를 읽어와서 변경하고, 다시 XLS로 저장한다. public bool ConvertTagXLS(string fileName, LocalizeSource localize) { string nakedFileName = System.IO.Path.GetFileName(fileName); Excel.Application app = new Excel.Application(); app.Workbooks.Open(fileName, 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]; Excel.Range rng; MH4Global.pgbXLS.Minimum = 2; MH4Global.pgbXLS.Maximum = sheet.UsedRange.Rows.Count + 1; MH4Global.lbXLS.Text = "Load and Convert to Japan XLS... : " + nakedFileName; MH4Global.lbXLS.Update(); if (MH4Global.IsSpecialQuestXLS(fileName)) // 스폐셜 퀘스트 문서 { for (int i = 2; i < sheet.UsedRange.Rows.Count + 1; ++i) { rng = sheet.UsedRange.get_Range("C" + i.ToString(), Missing.Value); if (rng.Value2 != null) { ReplaceTag(rng, localize); } rng = sheet.UsedRange.get_Range("H" + i.ToString(), Missing.Value); if (rng.Value2 != null) { ReplaceTag(rng, localize); } MH4Global.pgbXLS.Value = i; // 프로그레스바는 행단위로 표시한다. } } else // 일반 퀘스트 문서 { for (int i = 2; i < sheet.UsedRange.Rows.Count + 1; ++i) { for (int j = 1; j < MH4Global.colList.Length; ++j) { rng = (Excel.Range)sheet.UsedRange.Cells[i, MH4Global.colList[j]]; if (rng.Value2 != null) { ReplaceTag(rng, localize); } } MH4Global.pgbXLS.Value = i; // 프로그레스바는 행단위로 표시한다. } } app.ActiveWorkbook.Close(true, Missing.Value, Missing.Value); MH4Global.lbXLS.Text = "Load & Convert to XLS Complete : " + nakedFileName; MH4Global.lbXLS.Update(); return(true); }