public override void DealFile(string path) { try { DataTable dt = ImportFormExcel(path).Tables[0]; QFile qf = new QFile(); string lineno = dt.Rows[0][2].ToString().Trim(); string tmp = dt.Rows[0][3].ToString().Trim(); for (int i = 4; i < dt.Columns.Count; i++) { QParamter p = new QParamter(); p[2001] = (i - 3).ToString(); p[2002] = dt.Columns[i].Caption.Trim(); // dt.Rows[0][i].ToString().Trim(); p[2024] = tmp; Console.Write(dt.Columns[i].Caption); } for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][0].ToString().Length < 10) { break; } for (int j = 0; j < dt.Columns.Count; j++) { Console.WriteLine("{0}, {1}: {2}", i, j, dt.Rows[i][j].ToString().Trim()); } } } catch (Exception e1) { AddFailedFile(path, e1.Message); } }
private void LoadDefine(string path) { try { string content = ""; using (StreamReader sr = new StreamReader(path, Encoding.Default)) { content = sr.ReadToEnd(); } QFile qf = new QFile(); QParamter p = new QParamter(); string[] data = content.Split(';'); foreach (var item in data) { string[] dt = item.Split(','); for (int i = 0; i < names.Length; i++) { if (names[i] == dt[0]) { p[keys[i]] = dt[1]; break; } } } p.id = 1; qf.pramters.Add(p); qf.Tag = Path.GetFileNameWithoutExtension(path); qfs.Add(qf); } catch (Exception d1) { AddLog(path, d1.Message); } }
private QFile transfer(string path) { try { DataSet ds = ImportFormExcel(path); DataTable dt = ImportFormExcel(path).Tables[0]; int rows = dt.Rows.Count + 1; int cols = dt.Columns.Count; object[,] objs = new object[cols, rows]; for (int i = 0; i < dt.Columns.Count; i++) { objs[i, 0] = dt.Columns[i].Caption; } for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { objs[j, i + 1] = dt.Rows[i][j]; } } QFile qf = new QFile(); int count = (dt.Columns.Count - 3) / 4; qf[1002] = SheetName; qf[1005] = SheetName; for (int i = 0; i < count; i++) { QParamter p = new QParamter(); p.id = i + 1; p[2001] = objs[i * 4 + 6, 0].ToString(); p[2102] = double.Parse(objs[i * 4 + 3, 1].ToString()); p[2110] = double.Parse(objs[i * 4 + 4, 1].ToString()); p[2111] = double.Parse(objs[i * 4 + 5, 1].ToString()); double data = double.Parse(objs[i * 4 + 6, 1].ToString()); qf.pramters.Add(p); } int hcount = dt.Rows.Count / 2 + 1; for (int i = 0; i < hcount; i++) { QData data = new QData(); DateTime date = DateTime.Parse(objs[0, i * 2 + 1].ToString() + " " + objs[1, i * 2 + 1].ToString()); for (int j = 0; j < count; j++) { QDataItem di = new QDataItem(); di.date = date; string v = objs[j * 4 + 3, i * 2 + 1].ToString(); if (v == null || v.Length == 0) { di.p1 = 256; } else { di.value = double.Parse(v); } data.items.Add(di); } qf.data.Add(data); } return(qf); } catch (Exception e1) { AddLog(path, e1.Message); } return(null); }