private void setExcelDataToCurrentRelationContentDataGridView(string excelName) { InputExcel inputExcel = new InputExcel(relationExcelFolderPath + excelName); DataTable dataTable = inputExcel.ExcelToDataTable(loadGlobalChineseCharacters.GlobalChineseCharactersDict["relationContent"], isFirstRowColumn); this.currentRelationContentDataGridView.DataSource = dataTable; saveRelationExcelButton.Enabled = true; }
private void saveRelationExcelButton_Click(object sender, EventArgs e) { if (checkRelationContentData()) { DataTable dt = (currentRelationContentDataGridView.DataSource as DataTable); InputExcel inputExcel = new InputExcel(relationExcelFolderPath + currentEditRelationExcel); inputExcel.DataTableToExcel(dt, loadGlobalChineseCharacters.GlobalChineseCharactersDict["relationContent"]); } else { DialogResult dr1 = MessageBox.Show(loadGlobalChineseCharacters.GlobalChineseCharactersDict["exception12"], "exception"); } }
private void okButton_Click(object sender, EventArgs e) { List <string> thisTaskDateRelationCheckedList = new List <string>(); List <DateRelationDictionary> dateRelationDictionaryList = new List <DateRelationDictionary>(); for (int i = 0; i < thisTaskDateRelationCheckedListBox.Controls.Count; i++) { CheckBox checkBox = (CheckBox)thisTaskDateRelationCheckedListBox.Controls[i]; if (checkBox.Checked == true) { thisTaskDateRelationCheckedList.Add(checkBox.Text); } } foreach (string relationName in thisTaskDateRelationCheckedList) { DateRelationDictionary dateRelationDictionary = new DateRelationDictionary(); string[] relationColumns = relationName.Split(new char[1] { '-' }); char fristVariable = selectedColumnVariableDict[relationColumns[0]]; char secondVariable = selectedColumnVariableDict[relationColumns[1]]; dateRelationDictionary.variableName = fristVariable + "" + secondVariable; dateRelationDictionary.name = relationName; InputExcel inputExcel = new InputExcel(relationExcelFolderPath + relationName + ExcelHandle.excelExtensions[0]); DataTable dataTable = inputExcel.ExcelToDataTable(loadGlobalChineseCharacters.GlobalChineseCharactersDict["relationContent"], isFirstRowColumn); foreach (DataRow dr in dataTable.Rows) { if (!dr[0].Equals("") && !dr[1].Equals("")) { float year = Convert.ToSingle(dr[0]); float weight = Convert.ToSingle(dr[1]); dateRelationDictionary.Add(year, weight); dateRelationDictionaryList.Add(dateRelationDictionary); } } } //printThisTaskDateRelation(dateRelationDictionaryList); transmitData.dateRelationDictionaryList = dateRelationDictionaryList; this.Close(); }
private void OKbutton_Click(object sender, EventArgs e) { if (excelFilePath.Equals(PatternMatchingString.emptyString)) { DialogResult dr = MessageBox.Show(loadGlobalChineseCharacters.GlobalChineseCharactersDict["pleaseChooseExcelFile"], "regular expression result"); } else { InputExcel inputExcel = new InputExcel(excelFilePath); DataTable dataTable = inputExcel.ExcelToDataTable(loadGlobalChineseCharacters.GlobalChineseCharactersDict["customerLoanBill"], isFirstRowColumn); List <string> columnsNameList = getColumnName(dataTable); Dictionary <string, string> columnTypeDict = judgeColumnType(dataTable); //printColumnsName(columnsList); //List<ColumnType> columnTypeList = judgeColumnType(dataTable); //printColumnsType(columnTypeList); List <Column <string> > noRepeatingColumnList = handleData.filterRepeatingData(dataTable); //string columnStr = handleData.getColumnListString(columnList); //showMessage(columnStr); TransmitData transmitData = new TransmitData(dataTable, columnsNameList, columnTypeDict, noRepeatingColumnList); ChooseColumnForm chooseColumnForm = new ChooseColumnForm(transmitData); chooseColumnForm.Show(); } }
private void InputToExcel(object sender, RoutedEventArgs e) { ///弹出文件选择对话框,选取Excel文件 ///把Excel文件内容读至数组 ///把数组添加到表Inbound DataTable dt = InputExcel.GetTable(); if (dt != null) { if (dt.Rows.Count > 0) { List <Model.Inbound> lists = new List <Model.Inbound>(); for (int i = 0; i < dt.Rows.Count; i++) { Console.WriteLine(Convert.ToInt32(dt.Rows[i][0]) + "," + dt.Rows[i][1].ToString() + "," + dt.Rows[i][2].ToString() + "," + dt.Rows[i][4].ToString() + "," + dt.Rows[i][3].ToString() + "," + dt.Rows[i][5].ToString() + "," + dt.Rows[i][6].ToString() + "," + Convert.ToInt32(dt.Rows[i][7]) + "," + dt.Rows[i][8].ToString()); ///导入的数据模板 Model.Inbound u = new Model.Inbound(); u.Inbound_ID = dt.Rows[i][0].ToString(); u.Inbound_Time = dt.Rows[i][1].ToString(); u.Supplier_Name = dt.Rows[i][2].ToString(); u.Box_ID = dt.Rows[i][4].ToString(); u.Purchase_ID = dt.Rows[i][3].ToString(); u.Material_ID = dt.Rows[i][5].ToString(); u.Material_Spec = dt.Rows[i][6].ToString(); u.Material_PQty = Convert.ToInt32(dt.Rows[i][7]); u.Material_SerialNum = dt.Rows[i][8].ToString(); lists.Add(u); } datagridinbound.ItemsSource = lists; } } else { MessageBox.Show("excel表格式错误,请重新导入"); } }
public ActionResult Result(InputExcel data) { ResultModel result = data.Write(); return(View(result)); }