/// <summary> /// 学习经历导出 /// </summary> /// <param name="excel"></param> /// <param name="resumeid"></param> private void ExportStudyInfo(NCExcel excel, int resumeid) { DataSet ds = new DataSet(); if (db.GetSchool(0, 0, "[School],[Special],[Graduation],[StartDate],[EndDate]", "EmpId=" + resumeid.ToString(), "StartDate Desc", ref ds) && ds.Tables[0].Rows.Count > 0) { //获取技术者履历表中的 最终学历 excel.setValue(5, 9, ds.Tables[0].Rows[0]["School"].ToString()); //对应 技术者履历书 中的大学名 excel.setValue(16, 9, ds.Tables[0].Rows[0]["Special"].ToString()); //对应 技术者履历书 中的専門 excel.setValue(23, 9, ds.Tables[0].Rows[0]["EndDate"].ToString()); //对应 技术者履历书 中的卒業年月 excel.setValue(30, 9, ds.Tables[0].Rows[0]["Graduation"].ToString()); //对应 技术者履历书 中的学历 } }
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); 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].Replace("(", "").Replace(")", "")); execel.setValue(5, idx, tables[i].fields_size[j]); 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!"); } }
/// <summary> /// Create Publish /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPublish_Click(object sender, EventArgs e) { SaveFileDialog dlg = new SaveFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string fileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "コンサルテントテンプレート.xlsx"); NCExcel execel = new NCExcel(); execel.OpenExcelFile(fileName); execel.SelectSheet(1); int idx = 2; // add table list foreach (DataGridViewRow row in dgvData.Rows) { string companyName = row.Cells[1].Value.ToString(); string departName = row.Cells[14].Value.ToString(); string manager = row.Cells[2].Value.ToString(); string postcode = row.Cells[3].Value.ToString(); string address = row.Cells[4].Value.ToString(); string tel = row.Cells[5].Value.ToString(); string fax = row.Cells[6].Value.ToString(); string mail = row.Cells[12].Value.ToString(); string web = row.Cells[13].Value.ToString(); string comment = row.Cells[11].Value.ToString(); execel.setValue(1, idx, companyName); execel.setValue(2, idx, departName); execel.setValue(3, idx, comment); execel.setValue(4, idx, manager); execel.setValue(5, idx, mail); execel.setValue(6, idx, postcode); execel.setValue(7, idx, address); execel.setValue(8, idx, tel); execel.setValue(12, idx, fax); execel.setValue(13, idx, web); idx++; } execel.SaveAs(dlg.FileName); MessageBox.Show("Save ExcelOver!\r\n there are " + dgvData.Rows.Count + " record!"); } }
/// <summary> /// 工作经历导出 /// </summary> /// <param name="excel"></param> /// <param name="resumeid"></param> private void ExportWorkInfo(NCExcel excel, int resumeid) { DataSet ds = new DataSet(); if (db.GetWork(0, 0, "[StartDate],[EndDate],[Country],[Content],[Tool],[Role],[Range]", "EmpId=" + resumeid.ToString(), "StartDate", ref ds) && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int startRow = 58;//从第58行开始 int idx = i; if (i > 14) { excel.SelectSheet(2); //选择excel文件表中的第二张表 startRow = 9; //从第九行开始 idx = i - 15; } excel.setValue(3, startRow + 1 + idx * 3, ds.Tables[0].Rows[idx]["StartDate"].ToString()); //对应技术者履历书中的 期间(开始日期) excel.setValue(3, startRow + 2 + idx * 3, ds.Tables[0].Rows[idx]["EndDate"].ToString()); excel.setValue(6, startRow + 1 + idx * 3, ds.Tables[0].Rows[idx]["Country"].ToString()); //国家 excel.setValue(7, startRow + idx * 3, ds.Tables[0].Rows[idx]["Content"].ToString()); //对应技术者履历书中的 システム名その他 excel.setValue(15, startRow + idx * 3, ds.Tables[0].Rows[idx]["Tool"].ToString().Split('/')[0]); if (ds.Tables[0].Rows[idx]["Tool"].ToString().Split('/').Length > 2) { excel.setValue(15, startRow + 1 + idx * 3, ds.Tables[0].Rows[idx]["Tool"].ToString().Split('/')[1]); excel.setValue(15, startRow + 2 + idx * 3, ds.Tables[0].Rows[idx]["Tool"].ToString().Split('/')[2]); } excel.setValue(22, startRow + 1 + idx * 3, ds.Tables[0].Rows[idx]["Role"].ToString());//对应技术者履历书中的 担当 string range = ds.Tables[0].Rows[idx]["Range"].ToString(); if (!string.IsNullOrEmpty(range)) { string[] data = range.Split(':'); if (data.Length == 11) { for (int j = 0; j < 11; j++) { excel.setValue(23 + j, startRow + 1 + idx * 3, data[j]); } } } } } }
/// <summary> /// 基本信息导出 /// </summary> /// <param name="excel"></param> private void ExportBaseInfo(NCExcel excel, int resumeid) { DataSet ds = new DataSet(); if (db.GetEmp(0, 0, "Name,NameKana,Sex,Birthday,NearStation,Country,EnterDay", "EmpId=" + resumeid.ToString(), "", ref ds) && ds.Tables[0].Rows.Count == 1) { excel.setValue(30, 4, DateTime.Now.ToString()); //对应 技术者履历书作成日 excel.setValue(5, 5, ds.Tables[0].Rows[0]["NameKana"].ToString()); //对应 技术者履历书 中的フリガナ excel.setValue(5, 6, ds.Tables[0].Rows[0]["Name"].ToString()); //对应 技术者履历书 中的氏名 excel.setValue(10, 6, ds.Tables[0].Rows[0]["Sex"].ToString()); //对应 技术者履历书 中的性别 excel.setValue(12, 6, ds.Tables[0].Rows[0]["Birthday"].ToString()); //对应 技术者履历书 中的生年月 excel.setValue(20, 6, ds.Tables[0].Rows[0]["Country"].ToString()); //对应 技术者履历书 中的国籍 excel.setValue(23, 6, ds.Tables[0].Rows[0]["EnterDay"].ToString()); //对应 技术者履历书 中的入场日期 excel.setValue(27, 6, ds.Tables[0].Rows[0]["NearStation"].ToString()); //对应 技术者履历书 中的自宅・最寄り駅 } }
private void btnSave_Click(object sender, EventArgs e) { SaveFileDialog dlg = new SaveFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string fileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "お客様テンプレート.xlsx"); NCExcel execel = new NCExcel(); execel.OpenExcelFile(fileName); execel.SelectSheet(1); int idx = 3; // add table list foreach (DataGridViewRow row in dgvData.Rows) { string comment = row.Cells[0].Value.ToString(); string companyName = row.Cells[1].Value.ToString(); string departName = row.Cells[2].Value.ToString(); string address = row.Cells[3].Value.ToString(); companyName = companyName + departName; string[] strs = companyName.Split(' '); if (strs.Length == 2) { companyName = strs[0]; departName = strs[1]; } execel.setValue(2, idx, companyName); execel.setValue(3, idx, departName); execel.setValue(6, idx, address); execel.setValue(7, idx, comment); idx++; } execel.SaveAs(dlg.FileName); MessageBox.Show("Save Over!"); } }