使用c#.net从excel文件列表中选择最新的excel文件 [英] Select lates excel file from excel file list using c#.net

查看:78
本文介绍了使用c#.net从excel文件列表中选择最新的excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel文件列表,我想根据日期选择最新的excel文件.谁能告诉我这个代码.我想在c#.net中实现.
我的excel文件格式为:-Weekly_Monthly_Hours_Reference_Sheet_03-28-11.xls

I have a list of excel file and i want to select latest excel file on the basis of date.can anyone tell me the code for this.i want to achieve in c#.net.
My format of excel file is:--Weekly_Monthly_Hours_Reference_Sheet_03-28-11.xls

推荐答案

0)获取日期变量作为最新日期,并获取字符串变量作为文件. br/> 1)循环浏览excel文件.
1.1)获取文件名的最后8个字符.参考: GetFileNameWithoutExtension [子字符串 [ Convert.ToDateTime [
0) Get a date variable for latest date, and string variable for file.
1) Loop through the excel files.
1.1) Get the last 8 characters of name of the file. Ref: GetFileNameWithoutExtension[^], SubString[^]
1.2) Convert them to date. Ref: Convert.ToDateTime[^]
1.3) If it is newer then latest date or latest date is null then store date in latest date, and file name in file variable.
2) When you are out of loop, you''ll have the latest file in the file variable.


这篇关于使用c#.net从excel文件列表中选择最新的excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆