generate functionSun, 19 Mar 2023

una función que extraiga el nombre de las hojas de un archivo excel y las pase a un arreglo. Agregar

public void ReadExcelAndCreateArray(string FilePath) { string fileExtension = Path.GetExtension(FilePath); switch (fileExtension) { case ".xls": ReadXls(FilePath); break; case ".xlsx": ReadXlsx(FilePath); break; } public void ReadXls(string FilePath) { try { // Open the Excel file using ClosedXML. // Keep in mind the Excel file cannot be open when trying to read it using (XLWorkbook workBook = new XLWorkbook(FilePath)) { //Read the first Sheet from Excel file. IXLWorksheet workSheet = workBook.Worksheet(1); //Create a new DataTable. DataTable dt = new DataTable(); //Loop through the Worksheet rows. bool firstRow = true; foreach (IXLRow row in workSheet.Rows()) { //Use the

Questions about programming?Chat with your personal AI assistant