//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); }
//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); }
//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); }
//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); }