2024年1月25日发(作者:)

/// 字段或属性 /// 源对象 private ExcelSaveData GetExcelData(T Member, object SourceItem) where T : MemberInfo { ExcelSaveAttribute excelAtt = tomAttribute(); if (excelAtt == null) { //没有Excel保存特性

则退出 return null; } string _headname = tomAttribute().HeadName; int _priority = tomAttribute().Priority; bool _ValueToHeadName = tomAttribute().ValueToHeadName; string _MemberNameValue = tomAttribute().MemberNameToSave; object value; if (_ValueToHeadName) { string HeadNameV =""; string Value =""; Type t = e(); MemberInfo[] allinfo = bers(); if (Member is FieldInfo) { FieldInfo FieldMember = Member as FieldInfo; HeadNameV = ue(SourceItem).ToString(); } if (Member is PropertyInfo) { PropertyInfo ProMember = Member as PropertyInfo; HeadNameV = ue(SourceItem).ToString(); } foreach (var item in allinfo) { if ( == _MemberNameValue) { if (item is FieldInfo) { FieldInfo FieldMember = item as FieldInfo; Value = ue(SourceItem).ToString(); } if (item is PropertyInfo) { PropertyInfo ProMember = item as PropertyInfo; Value = ue(SourceItem).ToString(); } } } return new ExcelSaveData() { HeadName = HeadNameV, Priority = _priority ,Value = Value}; } if (Member is FieldInfo) { FieldInfo info = Member as FieldInfo; value = ue(SourceItem); if (value == null) { value = ""; } return new ExcelSaveData() { HeadName = _headname, Priority = _priority, Value = ng() }; } else if (Member is PropertyInfo) { PropertyInfo info = Member as PropertyInfo; value = ue(SourceItem); if (value == null)

if ((StartPoint.X - EndPoint.X > 0) || (StartPoint.Y - EndPoint.Y > 0)) return; string OperationPath; if (path == null) OperationPath = OperatorPath; else OperationPath = path; if (!(DefaultPath)) Directory(DefaultPath); IWorkbook ExcelBook = null; try { if (!(OperationPath)) (ModelPath, OperationPath); string AppExtensionName = ension(OperationPath); using (FileStream fs = (OperationPath, Create, ite)) { if (AppExtensionName == ".xlsx") ExcelBook = new XSSFWorkbook(fs); else if (AppExtensionName == ".xls") ExcelBook = new HSSFWorkbook(fs); ISheet Sheet = etAt(0); gedRegion(new ngeAddress(StartPoint.X, EndPoint.X, StartPoint.Y, EndPoint.Y)); HeadIndex = HeadIndex +(EndPoint.X - StartPoint.X) + 1; ICell cell = Row(StartPoint.X).CreateCell(StartPoint.Y); ICellStyle _NewStyle = CellStyle(); _ent = Selection; yle = _NewStyle; lValue(Value); ine(HeadIndex); } using (FileStream fs = ite(OperationPath)) { (fs); } } catch (Exception ex) { ine("Error!!" + ex); } }

public List ReadData(string path, string row) { int rownum; if (path == null) path = OperatorPath; if (se(row, out rownum) || (rownum > 0)) ine("OK"); else return null; if ((path)) { IWorkbook ExcelBook; try { using (FileStream fs = new FileStream(path, )) { ExcelBook = new HSSFWorkbook(fs); ISheet Sheet = etAt(0); IRow ReadRow = (rownum); if (ReadRow == null) return null; List Output = new List(); foreach (ICell cell in ) { (CellValue); } return Output; } } catch (Exception) { } } return null; }实现效果 private void button1_Click(object sender, EventArgs e) { List UploadData = new List(); TestClass1 t1 = new TestClass1() { RightHand = "OKRH",RightLeg = "OKRL",LeftHand = "OKLH",LeftLeg = "OKLL"}; TestClass3 t31 = new TestClass3() { ValueToName = "Test11111",Result = "OK"}; TestClass3 t32 = new TestClass3() { ValueToName = "Test22222" ,Result = "NG"}; (t1); (t31); (t32); ce().SaveExcelData(UploadData,null); }

本文发布于:2024-01-25,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标记成员变量属性效果

发布评论

评论列表(有0条评论)
    福州电脑网_福州电脑维修_福州电脑之家_福州iThome

    福州电脑网_福州电脑维修_福州电脑之家_福州iThome

    福州电脑维修网(fzithome.com)专业的电脑维修,笔记本维修,上门维修各种电脑,笔记本,平板等,快速上门.电脑知识频道内容覆盖:计算机资讯,电脑基础应用知识,各种电脑故障维修学习,电脑外设产品维修维护,病毒,软件,硬件,常识.