private void btnExcel_Click(object sender, EventArgs e) { SaveFileDialog dlg = new SaveFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string fileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "テーブル定義書.xls"); NCExcel execel = new NCExcel(); execel.OpenExcelFile(fileName); execel.SelectSheet(1); int idx = 7; // add table list foreach (Tbl tbl in tables) { execel.setValue(2, idx, (idx - 6).ToString()); execel.setValue(4, idx, tbl.name); idx++; } // add sheet execel.AddSheet(tables); // add sheet data for (int i = 0; i < tables.Count; i++) { execel.SelectSheet(i + 2); execel.setValue(2, 2, "HighwayHR"); execel.setValue(4, 2, "HRWeb"); execel.setValue(9, 2, "Highwayns"); execel.setValue(11, 2, DateTime.Now.ToString("yyyy/MM/dd")); execel.setValue(2, 4, tables[i].name); idx = 7; for (int j = 0; j < tables[i].fields.Count; j++) { execel.setValue(2, idx, (idx - 6).ToString()); execel.setValue(3, idx, tables[i].fields[j]); execel.setValue(4, idx, tables[i].fields_type[j]); execel.setValue(5, idx, tables[i].fields_size[j].Replace("(", "").Replace(")", "")); if (tables[i].fields_null[j] == "NOT NULL") { execel.setValue(7, idx, "○"); } if (tables[i].pk.IndexOf(tables[i].fields[j]) > -1) { execel.setValue(8, idx, "○"); } execel.setValue(9, idx, tables[i].fields_increase[j] + "/" + tables[i].fields_default[j] + "/" + tables[i].fields_sign[j]); idx++; } } execel.SaveAs(dlg.FileName); MessageBox.Show("Save Over!"); } }