public List <IDataTemplete> ReadExcel(Type type, string path, int sheetIndex = 0) { ConstructorInfo[] infos = type.GetConstructors(); int index = -1; for (int i = 0; i < infos.Length; i++) { if (infos[i].GetParameters().Length == 0) { index = i; } } List <IDataTemplete> data = new List <IDataTemplete>(); if (index != -1) { ExcelStream stream = new ExcelStream(); DataTableCollection collection = (DataTableCollection)stream.ReadResouce(path); for (int i = 3; i < collection[sheetIndex].Rows.Count; i++) { IDataTemplete temp = (IDataTemplete)infos[index].Invoke(new object[] { }); temp.DeSerialize(collection[sheetIndex].Rows[i].ItemArray); data.Add(temp); } } return(data); }
public void WriteToExcel(string path, string sheetName, string[,] content) { ExcelStream stream = new ExcelStream(); ExcelWriteArgs args = new ExcelWriteArgs(); args.Path = path; args.SheetName = sheetName; args.Content = content; stream.WriteResource(args); }
public DataTableCollection ReadExcel(string path) { ExcelStream stream = new ExcelStream(); return((DataTableCollection)stream.ReadResouce(path)); }