/// <summary> /// 通过excel文件获取波磨信息集合 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public List <CorrugationInfoModel> GetCorrugationInfoList(string filePath) { List <CorrugationInfoModel> list = new List <CorrugationInfoModel>(); FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);//打开模板 只读 HSSFWorkbook wb = new HSSFWorkbook(file); ISheet sheet = wb.GetSheetAt(0); for (int i = (sheet.FirstRowNum) + 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); CorrugationInfoModel model = new CorrugationInfoModel(); model.StartMile = row.GetCell(0) == null ? "" : row.GetCell(0).ToString(); model.EndMile = row.GetCell(1) == null ? "" : row.GetCell(1).ToString(); model.RmsValue = row.GetCell(2) == null ? "" : row.GetCell(2).ToString(); model.PeakValue = row.GetCell(3) == null ? "" : row.GetCell(3).ToString(); model.AvgSpeed = row.GetCell(4) == null ? "" : row.GetCell(4).ToString(); model.FirstBasicFrequency = row.GetCell(5) == null ? "" : row.GetCell(5).ToString(); model.WaveLength = row.GetCell(6) == null ? "" : row.GetCell(6).ToString(); model.EnergyRatio = row.GetCell(7) == null ? "" : row.GetCell(7).ToString(); list.Add(model); } return(list); }
private void SaveCorrugationInfo(List <double[]> bmInfoList, string channelName, InvalidDataProcessing.CalculateCorrugationClass calculateCorrugation) { if (bmInfoList != null) { List <CorrugationInfoModel> listModel = new List <CorrugationInfoModel>(); for (int i = 0; i < bmInfoList[0].Length; i++) { CorrugationInfoModel model = new CorrugationInfoModel(); model.StartMile = bmInfoList[0][i].ToString(); model.EndMile = bmInfoList[1][i].ToString(); model.RmsValue = bmInfoList[2][i].ToString(); model.PeakValue = bmInfoList[3][i].ToString(); model.AvgSpeed = bmInfoList[4][i].ToString(); model.FirstBasicFrequency = bmInfoList[5][i].ToString(); model.WaveLength = bmInfoList[6][i].ToString(); model.EnergyRatio = bmInfoList[7][i].ToString(); listModel.Add(model); } string folderPath = this.textBoxFileDirectory.Text; calculateCorrugation.CreateExcel(listModel, folderPath, channelName + "Info"); } }