From d0d5a89c59168fb034c808950f0b927d35294421 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 22 Feb 2022 06:53:00 -0700 Subject: [PATCH] --carga excel --- CRM/CatEmpresasCRM.aspx.cs | 80 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/CRM/CatEmpresasCRM.aspx.cs b/CRM/CatEmpresasCRM.aspx.cs index d7b7b4a1f..9001fb0c6 100644 --- a/CRM/CatEmpresasCRM.aspx.cs +++ b/CRM/CatEmpresasCRM.aspx.cs @@ -185,7 +185,7 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas Archivo file = TxtExcel.getfiles().Archivos[0]; string Directorio = Server.MapPath("~") + file.path; - DataTable dt = ReadExcelFile(Directorio + file.filename, true); + DataTable dt = ModExtensiones.ReadExcelFile(Directorio + file.filename, true); DataRowCollection Rows = dt.Rows; ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString); RequestMedioCaptacion RequestMedioCaptacion = new RequestMedioCaptacion(UsuarioActual.CveEmpresa); @@ -291,51 +291,51 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas } - private DataTable ReadExcelFile(string flatFilePath, bool firstRowHasHeaders) - { - SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet()); - ExcelFile excelFile = ExcelFile.Load(flatFilePath); + //private DataTable ReadExcelFile(string flatFilePath, bool firstRowHasHeaders) + //{ + // SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet()); + // ExcelFile excelFile = ExcelFile.Load(flatFilePath); - int unnamed = 0; - int cols; - string[] columns; - int curRow = 0; - int curCol = 0; - DataTable dataTable = new DataTable(); - ExcelWorksheet worksheet = excelFile.Worksheets[0]; + // int unnamed = 0; + // int cols; + // string[] columns; + // int curRow = 0; + // int curCol = 0; + // DataTable dataTable = new DataTable(); + // ExcelWorksheet worksheet = excelFile.Worksheets[0]; - for (cols = 0; cols <= worksheet.Rows[0].AllocatedCells.Count - 1; cols++) - { - if (firstRowHasHeaders) - { - if (worksheet.Rows[0].Cells[cols].Value != null) - dataTable.Columns.Add(worksheet.Rows[0].Cells[cols].Value.ToString().Trim()); - else - dataTable.Columns.Add("Unnamed Column " + (System.Threading.Interlocked.Increment(ref unnamed))); + // for (cols = 0; cols <= worksheet.Rows[0].AllocatedCells.Count - 1; cols++) + // { + // if (firstRowHasHeaders) + // { + // if (worksheet.Rows[0].Cells[cols].Value != null) + // dataTable.Columns.Add(worksheet.Rows[0].Cells[cols].Value.ToString().Trim()); + // else + // dataTable.Columns.Add("Unnamed Column " + (System.Threading.Interlocked.Increment(ref unnamed))); - curRow = 1; - } - else - dataTable.Columns.Add("Column " + (cols + 1)); - } + // curRow = 1; + // } + // else + // dataTable.Columns.Add("Column " + (cols + 1)); + // } - while (curRow < worksheet.Rows.Count) - { - columns = new string[cols - 1 + 1]; + // while (curRow < worksheet.Rows.Count) + // { + // columns = new string[cols - 1 + 1]; - for (curCol = 0; curCol <= cols - 1; curCol++) - { - if (worksheet.Rows[curRow].Cells[curCol].Value == null) - columns[curCol] = ""; - else - columns[curCol] = worksheet.Rows[curRow].Cells[curCol].Value.ToString(); - } + // for (curCol = 0; curCol <= cols - 1; curCol++) + // { + // if (worksheet.Rows[curRow].Cells[curCol].Value == null) + // columns[curCol] = ""; + // else + // columns[curCol] = worksheet.Rows[curRow].Cells[curCol].Value.ToString(); + // } - dataTable.Rows.Add(columns); - curRow += 1; - } + // dataTable.Rows.Add(columns); + // curRow += 1; + // } - return dataTable; - } + // return dataTable; + //} } \ No newline at end of file