public static void procesaFacturacion(string pathFacturas, string pathAvon) { ExcelInterop oEI = new ExcelInterop(); Worksheet xlWorkSheet; Workbook xlWorkBook; lstTransTarifa = readTransporteTarifa(); lstManioTarifa = readManiobraTarifa(); LogCtrl.writeLog("Termina lectura de tarifas..."); xlWorkBook = oEI.openBook(pathFacturas); LogCtrl.writeLog("Comienza lectura de facturas..."); List <factura> lst = new List <factura>(); for (int i = 1; i <= xlWorkBook.Worksheets.Count; i++) { try { xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(i); lst.Add(procesaHoja(xlWorkSheet)); xlWorkSheet = null; } catch (Exception e) { LogCtrl.writeLog(e.Message); } } oEI.closeBook(xlWorkBook); Console.WriteLine("Lectura de facturas completa"); #region Crea xls Avon xlWorkBook = oEI.openBook(getPathFile("PlantillaAvon.xlsx")); xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1); insertaParcialesColumnas(xlWorkSheet);//Inserta tantas columnas como el máximo número de parciales que se hayan registrado int fila = 2; foreach (factura item in lst) { try { insertaFila(xlWorkSheet, fila, item); fila++; } catch { } } Console.WriteLine("Escritura de facturas en la plantilla completa"); oEI.saveXls(xlWorkBook, xlWorkSheet, pathAvon.Replace("/", @"\")); #endregion //Console.Read(); }