private void btnLoadXML_Click(object sender, System.EventArgs e) { frmMain.labStatus.Text = ""; frmMain.msg.clear(); OpenFileDialog openFileDialog1 = new OpenFileDialog(); if (lstTemp.Tag != null && File.Exists(lstTemp.Tag.ToString())) { openFileDialog1.InitialDirectory = Path.GetFullPath(lstTemp.Tag.ToString()); } else { openFileDialog1.InitialDirectory = Path.GetFullPath(Application.ExecutablePath); } openFileDialog1.Filter = "クラステンプレート配置情報ファイル(*.xml)|*.xml"; openFileDialog1.Title = "クラステンプレートファイルを選択してください。"; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string[] sSelFileName = openFileDialog1.FileNames; lstTemp.Tag = sSelFileName[0]; for (int i = 0; i < sSelFileName.Length; i++) { if (lstTemp.FindString(sSelFileName[i]) >= 0) { continue; } frmMain.labStatus.Text = "Now is getting XML file information..."; Application.DoEvents(); XmlDocument xmldoc2 = getXMLTemplate(sSelFileName[i]); if (xmldoc2 == null) { frmMain.msg.println("Can not Load, Skip:" + sSelFileName[i]); continue; } XmlNodeList nodeList = xmldoc2.SelectNodes("config/template"); if (nodeList.Count > 0) { lstTemp.Items.Add(sSelFileName[i]); } for (int nodei = 0; nodei < nodeList.Count; nodei++) { if (nodeList[nodei].Attributes["title"] != null) { string slang = ""; if (nodeList[nodei].Attributes["language"] != null) { slang = "[" + nodeList[nodei].Attributes["language"].InnerText + "] "; } lstTemp.Items.Add(" " + slang + nodeList[nodei].Attributes["title"].InnerText); } } frmMain.labStatus.Text = "Now is getting XML file information...OK"; } } }
private void btnLoadExcel_Click(object sender, System.EventArgs e) { frmMain.labStatus.Text = ""; OpenFileDialog openFileDialog1 = new OpenFileDialog(); if (lstExcel.Tag != null && File.Exists(lstExcel.Tag.ToString())) { openFileDialog1.InitialDirectory = Path.GetFullPath(lstExcel.Tag.ToString()); } else { openFileDialog1.InitialDirectory = Path.GetFullPath(Application.ExecutablePath); } openFileDialog1.Filter = "テーブルレイアウトファイル(*.xls)|*.xls"; openFileDialog1.Title = "テーブルレイアウトファイルを選択してください。"; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string[] sExcelName = openFileDialog1.FileNames; lstExcel.Tag = sExcelName[0]; for (int i = 0; i < sExcelName.Length; i++) { if (lstExcel.FindString(sExcelName[i]) >= 0) { continue; } lstExcel.Items.Add(sExcelName[i]); frmMain.labStatus.Text = "Now is getting excle file information..."; Application.DoEvents(); string sConnExcel = cc.OleDB.ConnStringExcel(sExcelName[i], false); cc.OleDB dbExcel = new cc.OleDB(sConnExcel); if (dbExcel.Error()) { frmMain.msg.println("Open Excel File Error:"); frmMain.msg.println("File:" + sExcelName[i]); frmMain.msg.println(dbExcel.Exception.Message, Color.Red); return; } string[] sSheetsName = dbExcel.GetExcelSheetsName(); if (sSheetsName != null) { foreach (string s in sSheetsName) { lstExcel.Items.Add(" " + s); } } frmMain.labStatus.Text = "Now is getting excle file information...OK"; dbExcel.Dispose(); } } }