角度日期管道从实际日期值中减去一天

时间:2018-06-07 03:33:10

标签: angular6 angular-pipe

我不确定我是否需要在这里添加任何内容。我有一个带日期列的表。通过Angular日期管道处理日期列时,只需更改要显示的格式,它就会从实际日期中减去一天。我检查了它而没有添加日期管道,我得到了实际的日期。可能有什么不对?

    using (ExcelPackage pkg = new ExcelPackage())
        {
            var fullFilename = "warming up specification.xlsx";
            var oldFilePath = Server.MapPath("~/File" + "/" + fullFilename);

            using (FileStream stream = new FileStream(oldFilePath, FileMode.Open))
            {


                pkg.Load(stream);
                ExcelWorksheet ws = pkg.Workbook.Worksheets[1];


                //set Fixed Cell value
                foreach (var item in dict)
                {
                    ws.Cells[item.Key].Value = item.Value; 
                }
                ws.Cells.Style.Font.Size = 13;
                ws.Cells.Style.WrapText = true;
                ws.PrinterSettings.PaperSize = ePaperSize.A4;

                ws.PrinterSettings.FitToPage = true;
                ws.PrinterSettings.FooterMargin = 0M;
                ws.PrinterSettings.TopMargin = 0M;
                ws.PrinterSettings.LeftMargin = 0M;
                ws.PrinterSettings.RightMargin = 0M;

                ws.Cells["A1:AC1"].Merge = true;
                ws.Cells["A1:AC1"].Style.Font.Bold = true;
                ws.Cells["A1:AC1"].Style.Font.Size = 25;
                ws.Cells["A1:AC1"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                ws.Cells["A1:AC1"].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
                ws.Cells["A1:AC1"].Value = "TEST";
                // ws.Cells["F1:L1"].Style.Border.Bottom.Style = ws.Cells["F1:L1"].Style.Border.Left.Style = ws.Cells["F1:L1"].Style.Border.Right.Style = ws.Cells["F1:L1"].Style.Border.Top.Style = ExcelBorderStyle.Thin;

                Random rand = new Random();
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=" + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(1, 999) + "_" + fullFilename);
                Response.BinaryWrite(pkg.GetAsByteArray());
                Response.End();
        }

1 个答案:

答案 0 :(得分:0)

您是否在没有自定义格式的情况下尝试过它?

{{ workOrder.postDate | date: 'MMM d, y'}} 

应与

结果相同
{{ workOrder.postDate | date }} 

相同
{{workOrder.postDate | date:'mediumDate'}}

示例:https://jsfiddle.net/Scotty3/bdmqxr5y/4757/

https://next.angular.io/api/common/DatePipe

如果不是,您需要检查源日期变量。