我尝试在由office.interop创建的数据透视表中设置字段的计算
我需要设置DifferenceFromNext,但是在枚举中,我发现只是DifferenceFrom
public class CartViewModel
{
public List<CartItemModel> CartItemList { get; set; }
public decimal NetTotal { get; set; }
public CartViewModel()
{
CartItemList = new List<CartItemModel>();
}
}
public class CartItemModel
{
public long CartId { get; set; }
public long ProductId { get; set; }
public string ProductName { get; set; }
public string ProductImage { get; set; }
public string VariantName { get; set; }
public string VariantGroup { get; set; }
public short Quantity { get; set; }
public decimal Price { get; set; }
public decimal DiscountedPrice { get; set; }
public decimal TotalAmount { get; set; }
public bool IsPromotional { get; set; }
}
问题是它在错误的字段上计算
答案 0 :(得分:0)
解决了设置基础项目的问题,请确保在计算之前先进行设置,然后再设置基础项目,而不是引发异常
field.Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlDifferenceFrom;
field.BaseItem = "(next)";