谢谢三石大大,我刚才参考demo也看明白了
是和Grid的不一致的。需要从代码里面格式化。
- lz_ShopDetail shopDetail = total.ToList()[0];
- JObject summary = new JObject();
- summary.Add("shop_name", shopDetail.shop_name);
- summary.Add("date_type", shopDetail.date_type);
- summary.Add("pv", shopDetail.pv);
- summary.Add("uv", shopDetail.uv);
- summary.Add("view_repeat", shopDetail.view_repeat);
- summary.Add("view_repeat_rate", string.Format("{0:0.00%}", shopDetail.view_repeat_rate));
- summary.Add("avg_session_num", shopDetail.avg_session_num);
- summary.Add("gmv_auction_num", shopDetail.gmv_auction_num);
- summary.Add("gmv_trade_num", shopDetail.gmv_trade_num);
- summary.Add("gmv_parent_order_num", shopDetail.gmv_parent_order_num);
- summary.Add("gmv_trade_amt", shopDetail.gmv_trade_amt);
- summary.Add("alipay_winner_num", shopDetail.alipay_winner_num);
- summary.Add("trade_repeat", shopDetail.trade_repeat);
- summary.Add("alipay_auction_num", shopDetail.alipay_auction_num);
- summary.Add("alipay_trade_num", shopDetail.alipay_trade_num);
- summary.Add("alipay_parent_order_num", shopDetail.alipay_parent_order_num);
- summary.Add("alipay_trade_amt", shopDetail.alipay_trade_amt);
- summary.Add("avg_winner_num", string.Format("{0:F1}", shopDetail.avg_winner_num));
- summary.Add("avg_trade_num", string.Format("{0:F1}", shopDetail.avg_trade_num));
- summary.Add("avg_alipay_parent_order_num", string.Format("{0:F1}", shopDetail.avg_alipay_parent_order_num));
- summary.Add("today_auction_num", shopDetail.today_auction_num);
- summary.Add("today_trade_num", shopDetail.today_trade_num);
- summary.Add("today_order_num", shopDetail.today_order_num);
- summary.Add("today_trade_amt", shopDetail.today_trade_amt);
- summary.Add("ext", string.Format("{0:F}", shopDetail.ext));
- summary.Add("today_pay_rate", string.Format("{0:0.00%}", shopDetail.today_pay_rate));
- summary.Add("trade_repeat_rate", string.Format("{0:0.00%}", shopDetail.trade_repeat_rate));
- summary.Add("shop_trade_ex", string.Format("{0:0.00%}", shopDetail.shop_trade_ex));
- Grid1.SummaryData = summary;
复制代码
发现需要格式化的地方太多了。
下载引出EXCEL的时候又需要格式化一次。
用Demo中的引出Excel,是可以把已经格式化的数据直接导出Excel,但是只能引出当前页。
论坛中也有DataTable保存全量数据的,我这边用的EF,然后导出用NPOI。
数据查询结果出来了之后,再次格式化下。发现格式化的代码有点不一样。
- ICellStyle dateStyle = workbook.CreateCellStyle();
- dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");
- cell.CellStyle = dateStyle;
复制代码
这段代码是在NPOI中格式化的代码。
|