• 大小: 1.98M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-27
  • 语言: C#
  • 标签: Excel  CE  分析  导入  导出  

资源简介


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Functions
{
    public class BLL
    {
    /// 
    /// 获取EXCEL文件内容;
    /// 

    /// 
    /// 
        public static DataTable GetDataTable(string strExcelFileName)
        {
            string sExt = System.IO.Path.GetExtension(strExcelFileName);
            string sConn = null;
            if (sExt == “.xlsx“)
            {
                sConn = “Provider=Microsoft.ACE.OLEDB.12.0;“ + “Data Source=“ + strExcelFileName + “;“ + “Extended Properties=‘Excel 12.0;HDR=YES‘“;
            }
            else if (sExt == “.xls“)
            {
                sConn = “Provider=Microsoft.Jet.OLEDB.4.0;“ + “Data Source=“ + strExcelFileName + “;“ + “Extended Properties=Excel 8.0“;
            }
            else
            {
                throw new Exception(“文件格式有误“);
            }
            OleDbConnection oledbConn = new OleDbConnection(sConn);
            oledbConn.Open();
            OleDbDataAdapter command = new OleDbDataAdapter(“SELECT * FROM [Sheet1$]“ oledbConn);
            DataSet ds = new DataSet();
            command.Fill(ds);
            oledbConn.Close();
            return ds.Tables[0];

        }
        /// 
        /// 时间转换
        /// 

        /// 
        /// 
        public static DateTime Date_convertion(string datefild)
        {
            DateTime dt = new DateTime();
            DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();

            dtFormat.ShortDatePattern = “MM/dd/yyyy“;

            dt = Convert.ToDateTime(datefild dtFormat);

            return dt;
        }
        /// 
        /// 日期比较
        /// 

        /// 
        /// 
        /// 
       public static int DateDiff(string dateStart string dateEnd int daysp)
        {
            int check = 0;
            try
            {
                DateTime start = Date_convertion(dateStart);
                DateTime end = Date_convertion(dateEnd);
                TimeSpan sp = end.Subtract(start);
                if (sp.Days == daysp)
                {
                    check = 1;
                }
                else if (sp.Days == 0)
                {
                    check = 0;
                }
                else
                {
                    check = 2;
                }
            }
            catch
            {
                check = -1;
 
            }
            return check;

           
        }
        /// 
        /// 时间比较
        /// 

        /// 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1398  2019-12-18 15:48  Statistic.sln
     文件       64000  2019-12-26 08:54  Statistic.v11.suo
     文件      202108  2019-12-20 13:28  Testing.xlsx
     文件      232286  2019-12-20 15:53  操作说明文档.docx
     文件       32058  2019-12-26 08:54  导出excel.png
     文件       39948  2019-12-26 08:54  分析excel.png
     文件       41329  2019-12-26 08:53  提取文件内容.png
     目录           0  2020-02-12 20:50  Functions\
     目录           0  2020-02-12 20:50  Functions\bin\
     目录           0  2020-02-12 20:50  Functions\bin\Debug\
     文件        6144  2019-12-20 16:25  Functions\bin\Debug\Functions.dll
     文件       13824  2019-12-20 16:25  Functions\bin\Debug\Functions.pdb
     目录           0  2019-12-18 15:45  Functions\bin\Release\
     文件        3877  2019-12-20 09:35  Functions\BLL.cs
     文件        2403  2019-12-18 15:48  Functions\Functions.csproj
     目录           0  2020-02-12 20:50  Functions\obj\
     目录           0  2020-02-12 20:50  Functions\obj\Debug\
     文件        6503  2019-12-18 15:45  Functions\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         260  2019-12-20 16:25  Functions\obj\Debug\Functions.csproj.FileListAbsolute.txt
     文件        6144  2019-12-20 16:25  Functions\obj\Debug\Functions.dll
     文件       13824  2019-12-20 16:25  Functions\obj\Debug\Functions.pdb
     文件           0  2019-12-18 15:42  Functions\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2019-12-18 15:42  Functions\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2019-12-18 15:42  Functions\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2019-12-18 15:42  Functions\obj\Debug\TempPE\
     目录           0  2020-02-12 20:50  Functions\Properties\
     文件        1430  2019-12-18 15:42  Functions\Properties\AssemblyInfo.cs
     目录           0  2020-02-12 20:50  Statistic\
     文件         187  2019-12-17 11:04  Statistic\App.config
     目录           0  2020-02-12 20:50  Statistic\bin\
     目录           0  2020-02-12 20:50  Statistic\bin\Debug\
............此处省略41个文件信息

评论

共有 条评论