public void GetRpt_KmsRecorridos() { string fecDesde = "" + Request.QueryString["desde"]; string fecHasta = "" + Request.QueryString["hasta"]; string transportista = "" + Request.QueryString["transportista"]; string patente = "" + Request.QueryString["patente"]; DateTime _fecDesde; DateTime _fecHasta; if (DateTime.TryParseExact(fecDesde.Replace("-", "/").Substring(0, 16), "dd/MM/yyyy HH:mm", culture, DateTimeStyles.None, out _fecDesde)) { } else { DateTime.TryParseExact(fecDesde.Replace("T", " ").Substring(0, 16), "yyyy-MM-dd HH:mm", culture, DateTimeStyles.None, out _fecDesde); } if (DateTime.TryParseExact(fecHasta.Replace("-", "/").Substring(0, 16), "dd/MM/yyyy HH:mm", culture, DateTimeStyles.None, out _fecHasta)) { } else { DateTime.TryParseExact(fecHasta.Replace("T", " ").Substring(0, 16), "yyyy-MM-dd HH:mm", culture, DateTimeStyles.None, out _fecHasta); } Methods_Reportes _objMethodsReportes = new Methods_Reportes(); string _response = JsonConvert.SerializeObject(_objMethodsReportes.GetRpt_KmsRecorridos(_fecDesde, _fecHasta, transportista, patente)); Response.Write(_response); }
public void ExportExcel(string desde, string hasta, string transportista, string patente) { DateTime _desde; DateTime _hasta; //DateTime.TryParse(desde, out _desde); //DateTime.TryParse(hasta, out _hasta); if (DateTime.TryParseExact(desde.Replace("-", "/").Substring(0, 10), "dd/MM/yyyy", culture, DateTimeStyles.None, out _desde)) { } else { DateTime.TryParseExact(desde.Replace("T", " ").Substring(0, 10), "yyyy-MM-dd", culture, DateTimeStyles.None, out _desde); } if (DateTime.TryParseExact(hasta.Replace("-", "/").Substring(0, 10), "dd/MM/yyyy", culture, DateTimeStyles.None, out _hasta)) { } else { DateTime.TryParseExact(hasta.Replace("T", " ").Substring(0, 10), "yyyy-MM-dd", culture, DateTimeStyles.None, out _hasta); } string now = DateTime.Now.ToString(); now = now.Replace(" ", "_"); now = now.Replace("-", ""); now = now.Replace(":", ""); Methods_Reportes _objMethosReportes = new Methods_Reportes(); List <Track_GetRpt_KmsRecorridos_Result> _viajes = _objMethosReportes.GetRpt_KmsRecorridos(_desde, _hasta, transportista, patente); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("Content-Disposition", "attachment;filename=Reporte_KmsRecorridos_" + now + ".xls"); Response.Charset = "UTF-8"; Response.ContentEncoding = Encoding.Default; Response.Write(Methods_Export.HTML_RPT_KmsRecorridos(_viajes.ToList())); Response.End(); }