private void LoadEnv() { string envfile; string[] aryLine; m_sExcelSavePath = "c:\\sms"; m_sCrctPath = m_sExePath; envfile = m_sExePath + "\\sden.env"; if (System.IO.File.Exists(envfile) == true) { aryLine = m_libCmn.LoadFileLineSJIS(envfile); m_sExcelSavePath = aryLine[1]; if (aryLine[2] != "") { m_sCrctPath = aryLine[2]; } } envfile = m_sExePath + "\\sdenwait.txt"; if (System.IO.File.Exists(envfile) == true) { aryLine = m_libCmn.LoadFileLineSJIS(envfile); m_nWaitSecond = m_libCmn.StrToInt(aryLine[1]); } }
public Boolean Create() { String sMsg; string[] aryMsg; MessageBoxResult result; Boolean ret; if (System.IO.File.Exists(m_sCrctFile) == false) { sMsg = "貯込ファイルが見つかりません"; System.Windows.MessageBox.Show(sMsg, "エラー"); return(false); } if (System.IO.File.Exists(m_sSrcXlsFile) == false) { sMsg = "テンプレートファイルが見つかりません"; System.Windows.MessageBox.Show(sMsg, "エラー"); return(false); } if (System.IO.File.Exists(m_sDstXlsFile) == true) { sMsg = "同じ名前のファイルがありますので削除します"; result = System.Windows.MessageBox.Show(sMsg, "確認", MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { return(false); } System.IO.File.Delete(m_sDstXlsFile); } File.Copy(m_sSrcXlsFile, m_sDstXlsFile); try { if (m_libExcel.InitExcelApp() == false) { return(false); } } catch (Exception ex) { sMsg = ex.ToString(); aryMsg = sMsg.Split('\n'); System.Windows.MessageBox.Show(aryMsg[0], "エラー"); return(false); } try { m_aryLine = m_libCmn.LoadFileLineSJIS(m_sCrctFile); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "エラー"); m_libExcel.CloseExcelApp(); return(false); } m_nCrctLineCount = m_aryLine.Length; m_pgWnd = new ProgressWindows(); m_pgWnd.SetTitle(""); m_pgWnd.SetReng(0, m_nCrctLineCount); m_pgWnd.Show(); try { if (m_libExcel.InitExcelBook(m_sSrcXlsFile) == false) { m_libExcel.CloseExcelApp(); return(false); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "エラー"); //m_libExcel.EndExcelApp(); m_libExcel.CloseExcelApp(); return(false); } try { if (m_libExcel.InitDstExcelBook(m_sDstXlsFile) == false) { m_libExcel.CloseExcelBook(); m_libExcel.CloseExcelApp(); return(false); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "エラー"); m_libExcel.CloseExcelBook(); //m_libExcel.EndExcelApp(); m_libExcel.CloseExcelApp(); return(false); } try { SheetCreate(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "エラー"); m_libExcel.CloseDstExcelBook(); m_libExcel.CloseExcelBook(); //m_libExcel.EndExcelApp(); m_libExcel.CloseExcelApp(); return(false); } try { m_libExcel.EndDstExcelSave(); m_pgWnd.Close(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "エラー"); m_libExcel.CloseDstExcelBook(); m_libExcel.CloseExcelBook(); //m_libExcel.EndExcelApp(); m_libExcel.CloseExcelApp(); return(false); } m_libExcel.CloseDstExcelBook(); m_libExcel.CloseExcelBook(); //m_libExcel.EndExcelApp(); m_libExcel.CloseExcelApp(); return(true); }