Esempio n. 1
0
        //Get DataSheet
        public static System.Data.DataTable LoadDataSheet(string pathfile, string sheetname)
        {
            System.Data.DataTable tbl = null;
            bool is2007 = false;

            if (IsExcelFile(pathfile, out is2007))
            {
                IExcelFile excelfile = null;
                if (is2007)
                {
                    excelfile = new Excel2007(pathfile);
                }
                else
                {
                    excelfile = new Excel2003(pathfile);
                }

                tbl = excelfile.GetDataTable_SheetName(sheetname);
            }
            return(tbl);
        }
Esempio n. 2
0
        //Get FirstSheetName
        public static string GetFirstSheetName(string pathfile)
        {
            string firstsheet = "";
            bool   is2007     = false;

            if (IsExcelFile(pathfile, out is2007))
            {
                IExcelFile excelfile = null;
                if (is2007)
                {
                    excelfile = new Excel2007(pathfile);
                }
                else
                {
                    excelfile = new Excel2003(pathfile);
                }

                firstsheet = excelfile.GetFirstSheetName();
            }
            return(firstsheet);
        }
Esempio n. 3
0
        //Load Format of data in dataTable
        public static System.Data.DataTable LoadTableColumns(string pathfile)
        {
            System.Data.DataTable tbl = null;
            bool is2007 = false;

            if (IsExcelFile(pathfile, out is2007))
            {
                IExcelFile excelfile = null;
                if (is2007)
                {
                    excelfile = new Excel2007(pathfile);
                }
                else
                {
                    excelfile = new Excel2003(pathfile);
                }

                tbl = excelfile.GetDataTable_Format();
            }
            return(tbl);
        }
Esempio n. 4
0
        //Get number of rows data in file
        public static Int64 NumberRows(string pathfile, string sheetname)
        {
            int  num    = 0;
            bool is2007 = false;

            if (IsExcelFile(pathfile, out is2007))
            {
                IExcelFile excelfile = null;
                if (is2007)
                {
                    excelfile = new Excel2007(pathfile);
                }
                else
                {
                    excelfile = new Excel2003(pathfile);
                }

                num = excelfile.GetNumberRows(sheetname);
            }
            return(num);
        }