private System.Collections.Generic.List<WeekForExcel> GetMonthWeeks(int year, int month)
        {
            //weeks
            System.Collections.Generic.List<WeekForExcel> collWeeks = new System.Collections.Generic.List<WeekForExcel>();
            WeekForExcel week;
            int weekNumber = 1;
            System.DateTime weekStart = new System.DateTime(year, month, 1);
            DataTable weekTable = new DataTable();

            //days
            System.DateTime day;
            int dayNumberLast = System.DateTime.DaysInMonth(year, month);

            // creo una tabla dinámica para cada semana del mes
            for (int dayNumberCurrent = 1; dayNumberCurrent <= dayNumberLast; dayNumberCurrent++)
            {
                day = new System.DateTime(year, month, dayNumberCurrent);
                weekTable.Columns.Add(day.ToString("dd-MM-yy") + "-Detalle");
                weekTable.Columns.Add(day.ToString("dd-MM-yy") + "-Importe");

                if (day.DayOfWeek == System.DayOfWeek.Sunday)
                {
                    weekTable.Columns.Add("TotalWeek");
                    week = new WeekForExcel(weekNumber, weekStart, day, weekTable);
                    collWeeks.Add(week);

                    if (dayNumberCurrent != dayNumberLast)
                    {
                        weekStart = day.AddDays(1);
                        weekTable = new DataTable();
                        weekNumber++;
                    }
                }
                else if (dayNumberCurrent == dayNumberLast)
                {
                    weekTable.Columns.Add("TotalWeek");
                    week = new WeekForExcel(weekNumber, weekStart, day, weekTable);
                    collWeeks.Add(week);
                }
            }

            return collWeeks.OrderByDescending(l=>l.WeekNumber).ToList();
        }
        private void InsertWeek(ref ExcelWorksheet ws, WeekForExcel week)
        {
            var nameTable = ws.Names[string.Format("Tabla{0}", week.WeekNumber)];
            ws.InsertRow(nameTable.Start.Row, week.WeekTable.Rows.Count);

            var nameTableNew = ws.Cells[nameTable.Address].LoadFromDataTable(week.WeekTable, false);
            ws.Cells[nameTableNew.Address].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
            ws.Cells[nameTableNew.Address].Style.Fill.BackgroundColor.SetColor(System.Drawing.ColorTranslator.FromHtml("#FFFF99"));

            //estilo para el footer
            ExcelRange rangeFooter = ws.Cells[nameTableNew.End.Row, 1, nameTableNew.End.Row, nameTableNew.End.Column];
            rangeFooter.Style.Numberformat.Format = (this.IsPesosMoney) ? _format_pesos : _format_dollars;
            rangeFooter.Style.Font.Bold = true;
            foreach (var cell in rangeFooter)
                if (cell.Value != null && cell.Value.ToString() != "Total Día:")
                    cell.Value = decimal.Parse(cell.Value.ToString());

            this.SetBorders(ws.Cells[nameTableNew.Address]);
            this.PaintWeek(ref ws, nameTableNew.Address);
        }
 private decimal ExportWeek(WeekForExcel week, System.Collections.Generic.IEnumerable<IGrouping<System.DateTime, DAL.EF.AccountListing>> weekAccounts)
 {
     if (weekAccounts.Count() > 0)
         return this.ExportDays(week.WeekTable, weekAccounts);
     else
         return 0;
 }