private void RptBind(string _strWhere, string _orderby) { manager = GetAdminInfo(); if (!this.isSearch) { this.page = DTRequest.GetQueryInt("page", 1); } else { this.page = 1; } BLL.finance bll = new BLL.finance(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, manager, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = backUrl(); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); txtOrder.Text = _ordernum; txtCusName.Text = _cusname; hCusId.Value = _cusid; ddlcheck.SelectedValue = _status; txtsDate.Text = _smonth; txteDate.Text = _emonth; txtOsdate.Text = _sdate; txtOedate.Text = _edate; ddlsign.SelectedValue = _sign; txtMoney.Text = _money; ddlnature.SelectedValue = _nid; txtDetails.Text = _detail; ddlstatus.SelectedValue = _ostatus; ddllock.SelectedValue = _lock; ddlarea.SelectedValue = _area; txtPerson1.Text = _person1; txtPerson3.Text = _person3; txtPerson5.Text = _person5; ddlorderarea.SelectedValue = _orderarea; ddlfinarea.SelectedValue = _finarea; }
private void ShowInfo(int _id) { BLL.finance bll = new BLL.finance(); DataSet ds = bll.GetList(0, "fin_id=" + _id + "", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; this.oID = dr["fin_oid"].ToString(); this.type = bool.Parse(dr["fin_type"].ToString()); if (this.type) { typeText = "应收"; } else { typeText = "应付"; } txtCusName.Text = dr["c_name"].ToString(); hCusId.Value = dr["fin_cid"].ToString(); ddlnature.Visible = false; //ddlnature.SelectedValue = dr["fin_nature"].ToString(); labnature.Text = dr["na_name"].ToString(); if (!Convert.ToBoolean(dr["na_type"])) { detail1.Visible = true; detail2.Visible = false; ddldetail.DataSource = new BLL.businessDetails().GetList(0, " de_nid =" + dr["fin_nature"] + " and de_isUse=1 ", "de_sort asc,de_id desc"); ddldetail.DataTextField = "de_name"; ddldetail.DataValueField = "de_name"; ddldetail.DataBind(); ddldetail.Items.Insert(0, new ListItem("请选择", "")); ddldetail.SelectedValue = dr["fin_detail"].ToString(); } else { detail1.Visible = false; detail2.Attributes.Add("style", "display:block;"); //林智斌|SY002|SY,林蕴钊|SY003|SY,段强|SY004|SY if (!string.IsNullOrEmpty(dr["fin_detail"].ToString())) { string[] list = dr["fin_detail"].ToString().Split(','); DataTable dt = new DataTable(); dt.Columns.Add("op_name"); dt.Columns.Add("op_number"); dt.Columns.Add("op_area"); DataRow drr = dt.NewRow(); foreach (string item in list) { string[] nlist = item.Split('|'); drr = dt.NewRow(); drr["op_name"] = nlist[0]; drr["op_number"] = nlist[1]; drr["op_area"] = nlist[2]; dt.Rows.Add(drr); } rptEmployee2.DataSource = dt; rptEmployee2.DataBind(); } } //txtsDate.Text = Convert.ToDateTime(dr["fin_sdate"]).ToString("yyyy-MM-dd"); //txteDate.Text = Convert.ToDateTime(dr["fin_edate"]).ToString("yyyy-MM-dd"); txtIllustration.Text = dr["fin_illustration"].ToString(); txtExpression.Text = dr["fin_expression"].ToString(); txtMoney.Text = dr["fin_money"].ToString(); //minDate = ConvertHelper.toDate(dr["o_sdate"]).Value.ToString("yyyy-MM-dd"); //maxDate = ConvertHelper.toDate(dr["o_edate"]).Value.ToString("yyyy-MM-dd"); } }
private void RptBind() { this.page = DTRequest.GetQueryInt("page", 1); BLL.finance bll = new BLL.finance(); string _where = ""; Dictionary <string, string> dict = getDict(out _where); DataTable dt = bll.getReconciliationDetail(dict, this.pageSize, this.page, "o_id asc", out this.totalCount, out _p24, out _p25, out _p26, out _p13, out _p14).Tables[0]; int _colspan = 1; DataTable finDt = null; if (dt.Rows.Count > 0) { #region 拼接列表Html foreach (DataRow dr in dt.Rows) { if (!string.IsNullOrEmpty(oidStr) && oidStr.IndexOf(dr["o_id"].ToString()) == -1) { continue; } finDt = bll.GetList(0, "fin_oid='" + dr["o_id"] + "'" + _where, "").Tables[0]; _colspan = finDt.Rows.Count == 0 ? 1 : finDt.Rows.Count; trHtml += "<tr style=\"text-align: center;\">"; trHtml += "<td rowspan=\"" + _colspan + "\"><a href=\"../order/order_edit.aspx?action=" + DTEnums.ActionEnum.Edit.ToString() + "&oID=" + dr["o_id"] + "\">" + dr["o_id"] + "</a></td>"; trHtml += "<td style=\"text-align: left;\" rowspan=\"" + _colspan + "\">" + dr["o_content"] + "</td>"; trHtml += "<td rowspan=\"" + _colspan + "\">" + ConvertHelper.toDate(finDt.Rows[0]["o_sdate"]).Value.ToString("yyyy-MM-dd") + "<br/>" + ConvertHelper.toDate(finDt.Rows[0]["o_edate"]).Value.ToString("yyyy-MM-dd") + "</td>"; if (finDt == null || finDt.Rows.Count == 0) { //trHtml += "<td></td>"; trHtml += "<td></td>"; trHtml += "<td></td>"; trHtml += "<td></td>"; } else { //trHtml += "<td>" + ConvertHelper.toDate(finDt.Rows[0]["fin_sdate"]).Value.ToString("yyyy-MM-dd") + "<br/>" + ConvertHelper.toDate(finDt.Rows[0]["fin_edate"]).Value.ToString("yyyy-MM-dd") + "</td>"; trHtml += "<td style=\"text-align: left;\">" + finDt.Rows[0]["na_name"] + "<br/>" + finDt.Rows[0]["fin_detail"] + "</td>"; trHtml += "<td>" + finDt.Rows[0]["fin_illustration"] + "</td>"; trHtml += "<td style=\"word-wrap:break-word;word-break:break-all;\">" + finDt.Rows[0]["fin_expression"] + "<br/>=" + finDt.Rows[0]["fin_money"] + "</td>"; } trHtml += "<td style=\"text-align: right;\" rowspan=\"" + _colspan + "\">" + (string.IsNullOrEmpty(_chk) ? dr["fin_money"] : dr["fcMoney"]) + "</td>"; trHtml += "<td style=\"text-align: right;\" rowspan=\"" + _colspan + "\">" + (string.IsNullOrEmpty(_chk) ? dr["rpd_money"] : dr["chkMoney"]) + "</td>"; trHtml += "<td style=\"text-align: right;\" rowspan=\"" + _colspan + "\">" + (string.IsNullOrEmpty(_chk) ? dr["unReceiptPay"] : dr["unChkMoney"]) + "</td>"; trHtml += "<td rowspan=\"" + _colspan + "\">" + dr["co_name"] + "</td>"; trHtml += "</tr>"; if (finDt != null && finDt.Rows.Count > 1) { for (int i = 1; i < finDt.Rows.Count; i++) { trHtml += "<tr style=\"text-align: center;\">"; //trHtml += "<td>" + ConvertHelper.toDate(finDt.Rows[i]["fin_sdate"]).Value.ToString("yyyy-MM-dd") + "<br/>" + ConvertHelper.toDate(finDt.Rows[i]["fin_edate"]).Value.ToString("yyyy-MM-dd") + "</td>"; trHtml += "<td style=\"text-align: left;\">" + finDt.Rows[i]["na_name"] + "<br/>" + finDt.Rows[i]["fin_detail"] + "</td>"; trHtml += "<td>" + finDt.Rows[i]["fin_illustration"] + "</td>"; trHtml += "<td style=\"word-wrap:break-word;word-break:break-all;\">" + finDt.Rows[i]["fin_expression"] + "<br/>=" + finDt.Rows[i]["fin_money"] + "</td>"; trHtml += "</tr>"; } } } trHtml += "<tr style=\"text-align: right;\"><td colspan=\"6\">合计:</td><td>" + _p24 + "</td><td>" + _p25 + "</td><td>" + _p26 + "</td><td></td></tr>"; #endregion } else { trHtml = "<tr><td align=\"center\" colspan=\"10\">暂无记录</td></tr>"; } //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("ReconciliationBill.aspx", "page={0}&txtCusName={1}&hCusId={2}&ddltype={3}&ddlsign={4}&txtMoney1={5}&ddlnature={6}&txtsDate={7}&txteDate={8}&txtsDate1={9}&txteDate1={10}&txtName={11}&txtAddress={12}&ddlsign1={13}&txtMoney2={14}&txtPerson1={15}&txtPerson2={16}&txtPerson3={17}&txtPerson4={18}&txtPerson5={19}&txtOrderID={20}&txtChk={21}&ddlstatus={22}&ddllock={23}&ddlarea={24}&txtsDate2={25}&txteDate2={26}&txtsDate3={27}&txteDate3={28}&self={29}", "__id__", _cusName, _cid, _type, _sign, _money1, _nature, _sdate, _edate, _sdate1, _edate1, _name, _address, _sign1, _money2, _person1, _person2, _person3, _person4, _person5, _oid, _chk, _status, _lockstatus, _area, _sdate2, _edate2, _sdate3, _edate3, _self); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind() { if (!this.isSearch) { this.page = DTRequest.GetQueryInt("page", 1); } else { this.page = 1; } BLL.finance bll = new BLL.finance(); string _where = ""; Dictionary <string, string> dict = getDict(out _where); DataTable dt = bll.getReconciliationDetail(dict, this.pageSize, this.page, "o_id asc", out this.totalCount, out _p24, out _p25, out _p26, out _p13, out _p14).Tables[0]; int _colspan = 1; DataTable finDt = null; if (dt.Rows.Count > 0) { #region 拼接列表Html foreach (DataRow dr in dt.Rows) { finDt = bll.GetList(0, "fin_oid='" + dr["o_id"] + "'" + _where, _chk, "").Tables[0]; _colspan = finDt.Rows.Count == 0 ? 1 : finDt.Rows.Count; trHtml += "<tr style=\"text-align: center;\">"; trHtml += "<td rowspan=\"" + _colspan + "\"><input type=\"checkbox\" class=\"checkall\" data-id=\"" + dr["o_id"] + "\" data-finmoney=\"" + dr["fin_money"] + "\" data-rpdmoney=\"" + dr["rpd_money"] + "\" data-unMoney=\"" + dr["unReceiptPay"] + "\" data-unchkmoney=\"" + (string.IsNullOrEmpty(_chk) ? "--" : "" + dr["unChkMoney"] + "") + "\" data-unrpmoney=\"" + (string.IsNullOrEmpty(_chk) ? "" + dr["unReceiptPay"] + "" : "" + dr["unChkMoney"] + "") + "\"/></td>"; trHtml += "<td rowspan=\"" + _colspan + "\"><a href=\"../order/order_edit.aspx?action=" + DTEnums.ActionEnum.Edit.ToString() + "&oID=" + dr["o_id"] + "\"><span class=\"orderstatus_" + dr["o_status"] + "\">" + dr["o_id"] + "</span></a></td>"; trHtml += "<td style=\"text-align: left;\" rowspan=\"" + _colspan + "\">" + dr["c_name"] + "</td>"; trHtml += "<td rowspan=\"" + _colspan + "\">" + ConvertHelper.toDate(dr["o_sdate"]).Value.ToString("yyyy-MM-dd") + "<br/>" + ConvertHelper.toDate(dr["o_edate"]).Value.ToString("yyyy-MM-dd") + "</td>"; trHtml += "<td style=\"text-align: left;\" rowspan=\"" + _colspan + "\">" + dr["o_address"] + "/" + dr["o_content"] + "</td>"; if (finDt == null || finDt.Rows.Count == 0) { trHtml += "<td></td>"; trHtml += "<td></td>"; trHtml += "<td></td>"; //trHtml += "<td></td>"; trHtml += "<td></td>"; trHtml += "<td></td>"; trHtml += "<td></td>"; trHtml += "<td></td>"; } else { _p11 += Utils.ObjToDecimal(finDt.Rows[0]["chkMoney"], 0); trHtml += "<td><input type=\"checkbox\" class=\"check\" data-oid=\"" + dr["o_id"] + "\" data-id=\"" + finDt.Rows[0]["fin_id"] + "\" data-money=\"" + finDt.Rows[0]["fin_money"] + "\" data-chkmoney=\"" + finDt.Rows[0]["chkMoney"] + "\" /></td>"; trHtml += "<td style=\"word-wrap:break-word;word-break:break-all;\"><a href=\"javascript:;\" onclick=\"addFinChk(" + finDt.Rows[0]["fin_id"] + ",'" + finDt.Rows[0]["fin_oid"] + "')\">" + finDt.Rows[0]["chk"] + "</a></td>"; trHtml += "<td style=\"text-align: right;\">" + finDt.Rows[0]["chkMoney"] + "</td>"; //trHtml += "<td>" + ConvertHelper.toDate(finDt.Rows[0]["fin_sdate"]).Value.ToString("yyyy-MM-dd") + "<br/>" + ConvertHelper.toDate(finDt.Rows[0]["fin_edate"]).Value.ToString("yyyy-MM-dd") + "</td>"; trHtml += "<td style=\"text-align: center;\">" + finDt.Rows[0]["na_name"] + "<br/>" + finDt.Rows[0]["fin_detail"] + "</td>"; trHtml += "<td title=\"" + finDt.Rows[0]["fin_illustration"] + "\">" + (finDt.Rows[0]["fin_illustration"].ToString().Length <= 30 ? finDt.Rows[0]["fin_illustration"].ToString() : finDt.Rows[0]["fin_illustration"].ToString().Substring(0, 30)) + "</td>"; trHtml += "<td style=\"word-wrap:break-word;word-break:break-all;\">" + finDt.Rows[0]["fin_expression"] + "<br/>=" + finDt.Rows[0]["fin_money"] + "</td>"; trHtml += "<td><span onmouseover=\"tip_index = layer.tips('审批人:" + finDt.Rows[0]["fin_checkNum"] + "-" + finDt.Rows[0]["fin_checkName"] + "<br/>审批备注:" + finDt.Rows[0]["fin_checkRemark"] + "', this, { time: 0 }); \" onmouseout=\"layer.close(tip_index); \" class=\"check_" + finDt.Rows[0]["fin_flag"] + "\"></span></td>"; } trHtml += "<td style=\"text-align: right;\" rowspan=\"" + _colspan + "\">" + ((string.IsNullOrEmpty(_chk) || _chk == "空")? "" : "<font color='green'>" + dr["fcMoney"] + "/</font>") + "" + dr["fin_money"] + "</td>"; trHtml += "<td style=\"text-align: right;\" rowspan=\"" + _colspan + "\">" + ((string.IsNullOrEmpty(_chk) || _chk == "空")? "" : "<font color='green'>" + dr["chkMoney"] + "/</font>") + "" + dr["rpd_money"] + "</td>"; trHtml += "<td style=\"text-align: right;\" rowspan=\"" + _colspan + "\">" + ((string.IsNullOrEmpty(_chk) || _chk == "空")? "" : "<font color='green'>" + dr["unChkMoney"] + "/</font>") + "" + dr["unReceiptPay"] + "</td>"; trHtml += "</tr>"; if (!string.IsNullOrEmpty(_chk)) { _p12 += Utils.ObjToDecimal(dr["unChkMoney"], 0); } _p21 += Utils.ObjToDecimal(dr["fin_money"], 0); _p22 += Utils.ObjToDecimal(dr["rpd_money"], 0); _p23 += Utils.ObjToDecimal(dr["unReceiptPay"], 0); if (finDt != null && finDt.Rows.Count > 1) { for (int i = 1; i < finDt.Rows.Count; i++) { trHtml += "<tr style=\"text-align: center;\">"; trHtml += "<td><input type=\"checkbox\" class=\"check\" data-oid=\"" + dr["o_id"] + "\" data-id=\"" + finDt.Rows[i]["fin_id"] + "\" data-money=\"" + finDt.Rows[i]["fin_money"] + "\" data-chkmoney=\"" + finDt.Rows[i]["chkMoney"] + "\" /></td>"; trHtml += "<td style=\"word-wrap:break-word;word-break:break-all;\"><a href=\"javascript:;\" onclick=\"addFinChk(" + finDt.Rows[i]["fin_id"] + ",'" + finDt.Rows[i]["fin_oid"] + "')\">" + finDt.Rows[i]["chk"] + "</a></td>"; trHtml += "<td style=\"text-align: right;\">" + finDt.Rows[i]["chkMoney"] + "</td>"; //trHtml += "<td>" + ConvertHelper.toDate(finDt.Rows[i]["fin_sdate"]).Value.ToString("yyyy-MM-dd") + "<br/>" + ConvertHelper.toDate(finDt.Rows[i]["fin_edate"]).Value.ToString("yyyy-MM-dd") + "</td>"; trHtml += "<td style=\"text-align: center;\">" + finDt.Rows[i]["na_name"] + "<br/>" + finDt.Rows[i]["fin_detail"] + "</td>"; trHtml += "<td title=\"" + finDt.Rows[i]["fin_illustration"] + "\">" + (finDt.Rows[i]["fin_illustration"].ToString().Length <= 30 ? finDt.Rows[i]["fin_illustration"].ToString() : finDt.Rows[i]["fin_illustration"].ToString().Substring(0, 30)) + "</td>"; trHtml += "<td style=\"word-wrap:break-word;word-break:break-all;\">" + finDt.Rows[i]["fin_expression"] + "<br/>=" + finDt.Rows[i]["fin_money"] + "</td>"; trHtml += "<td><span onmouseover=\"tip_index = layer.tips('审批人:" + finDt.Rows[i]["fin_checkNum"] + "-" + finDt.Rows[i]["fin_checkName"] + "<br/>审批备注:" + finDt.Rows[i]["fin_checkRemark"] + "', this, { time: 0 }); \" onmouseout=\"layer.close(tip_index); \" class=\"check_" + finDt.Rows[i]["fin_flag"] + "\"></span></td>"; trHtml += "</tr>"; _p11 += Utils.ObjToDecimal(finDt.Rows[i]["chkMoney"], 0); } } } #endregion } else { trHtml = "<tr><td align=\"center\" colspan=\"14\">暂无记录</td></tr>"; } p11.Text = _p11.ToString(); if (!string.IsNullOrEmpty(_chk)) { p12.Text = _p12.ToString(); p14.Text = _p14.ToString(); } else { p12.Text = "--"; p14.Text = "--"; } p13.Text = _chk == "空"?"0":_p13.ToString(); p21.Text = _p21.ToString(); p22.Text = _p22.ToString(); p23.Text = _p23.ToString(); p24.Text = _p24.ToString(); p25.Text = _p25.ToString(); p26.Text = _p26.ToString(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = backUrl(); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); ddltype.SelectedValue = _type; txtCusName.Text = _cusName; hCusId.Value = _cid; txtCustomer.Text = _customer; hCustomer.Value = _hcustomer; txtsDate.Text = _sdate; txteDate.Text = _edate; txtsDate1.Text = _sdate1; txteDate1.Text = _edate1; txtsDate2.Text = _sdate2; txteDate2.Text = _edate2; //txtsDate3.Text = _sdate3; //txteDate3.Text = _edate3; ddlstatus.SelectedValue = _status; ddlsign.SelectedValue = _sign; txtMoney1.Text = _money1; ddlsign1.SelectedValue = _sign1; txtMoney2.Text = _money2; ddlnature.SelectedValue = _nature; txtChk.Text = _chk; ddlarea.SelectedValue = _area; ddllock.SelectedValue = _lockstatus; txtOrderID.Text = _oid; txtName.Text = _name; txtAddress.Text = _address; txtPerson1.Text = _person1; txtPerson2.Text = _person2; txtPerson3.Text = _person3; txtPerson4.Text = _person4; txtPerson5.Text = _person5; ddlcheck.SelectedValue = _check; txtDetails.Text = _detail; }
protected void btnExcel_Click(object sender, EventArgs e) { _ordernum = DTRequest.GetFormString("txtOrder"); _cusname = DTRequest.GetFormString("txtCusName"); _cusid = DTRequest.GetFormString("hCusId"); _status = DTRequest.GetFormString("ddlcheck"); _type = DTRequest.GetFormString("type"); _smonth = DTRequest.GetFormString("txtsDate"); _emonth = DTRequest.GetFormString("txteDate"); _sdate = DTRequest.GetFormString("txtOsdate"); _edate = DTRequest.GetFormString("txtOedate"); _sign = DTRequest.GetFormString("ddlsign"); _money = DTRequest.GetFormString("txtMoney"); _nid = DTRequest.GetFormString("ddlnature"); _detail = DTRequest.GetFormString("txtDetails"); _ostatus = DTRequest.GetFormString("ddlstatus"); _lock = DTRequest.GetFormString("ddllock"); _area = DTRequest.GetFormString("ddlarea"); _person1 = DTRequest.GetFormString("txtPerson1"); _person3 = DTRequest.GetFormString("txtPerson3"); _person5 = DTRequest.GetFormString("txtPerson5"); _orderarea = DTRequest.GetFormString("ddlorderarea"); _finarea = DTRequest.GetFormString("ddlfinarea"); BLL.finance bll = new BLL.finance(); manager = GetAdminInfo(); DataTable dt = bll.GetList(this.pageSize, this.page, "fin_type='" + (_type == "true" ? "True" : "False") + "'" + CombSqlTxt(), "fin_adddate desc,fin_id desc", manager, out this.totalCount, false).Tables[0]; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + ((_type == "true" ? "应收列表" : "应付列表")) + ".xlsx"); //HttpUtility.UrlEncode(fileName)); HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HSSFWorkbook hssfworkbook = new HSSFWorkbook(); ISheet sheet = hssfworkbook.CreateSheet("明细"); IFont font = hssfworkbook.CreateFont(); font.Boldweight = short.MaxValue; font.FontHeightInPoints = 11; #region 表格样式 //设置单元格的样式:水平垂直对齐居中 ICellStyle cellStyle = hssfworkbook.CreateCellStyle(); cellStyle.Alignment = HorizontalAlignment.Center; cellStyle.VerticalAlignment = VerticalAlignment.Center; cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BottomBorderColor = HSSFColor.Black.Index; cellStyle.LeftBorderColor = HSSFColor.Black.Index; cellStyle.RightBorderColor = HSSFColor.Black.Index; cellStyle.TopBorderColor = HSSFColor.Black.Index; cellStyle.WrapText = true;//自动换行 //设置表头的样式:水平垂直对齐居中,加粗 ICellStyle titleCellStyle = hssfworkbook.CreateCellStyle(); titleCellStyle.Alignment = HorizontalAlignment.Center; titleCellStyle.VerticalAlignment = VerticalAlignment.Center; titleCellStyle.FillForegroundColor = HSSFColor.Grey25Percent.Index; //图案颜色 titleCellStyle.FillPattern = FillPattern.SparseDots; //图案样式 titleCellStyle.FillBackgroundColor = HSSFColor.Grey25Percent.Index; //背景颜色 //设置边框 titleCellStyle.BorderBottom = BorderStyle.Thin; titleCellStyle.BorderLeft = BorderStyle.Thin; titleCellStyle.BorderRight = BorderStyle.Thin; titleCellStyle.BorderTop = BorderStyle.Thin; titleCellStyle.BottomBorderColor = HSSFColor.Black.Index; titleCellStyle.LeftBorderColor = HSSFColor.Black.Index; titleCellStyle.RightBorderColor = HSSFColor.Black.Index; titleCellStyle.TopBorderColor = HSSFColor.Black.Index; //设置字体 titleCellStyle.SetFont(font); #endregion //表头 IRow headRow = sheet.CreateRow(0); headRow.HeightInPoints = 25; headRow.CreateCell(0).SetCellValue("订单号"); headRow.CreateCell(1).SetCellValue("" + (_type == "true" ? "应收对象" : "应付对象") + ""); headRow.CreateCell(2).SetCellValue("对账凭证"); headRow.CreateCell(3).SetCellValue("业务性质/明细"); //headRow.CreateCell(4).SetCellValue("业务日期"); headRow.CreateCell(4).SetCellValue("订单日期"); headRow.CreateCell(5).SetCellValue("业务说明"); headRow.CreateCell(6).SetCellValue("金额表达式"); headRow.CreateCell(7).SetCellValue("金额"); headRow.CreateCell(8).SetCellValue("区域"); headRow.CreateCell(9).SetCellValue("结账月份"); headRow.CreateCell(10).SetCellValue("审批状态"); headRow.CreateCell(11).SetCellValue("添加人"); headRow.GetCell(0).CellStyle = titleCellStyle; headRow.GetCell(1).CellStyle = titleCellStyle; headRow.GetCell(2).CellStyle = titleCellStyle; headRow.GetCell(3).CellStyle = titleCellStyle; headRow.GetCell(4).CellStyle = titleCellStyle; headRow.GetCell(5).CellStyle = titleCellStyle; headRow.GetCell(6).CellStyle = titleCellStyle; headRow.GetCell(7).CellStyle = titleCellStyle; headRow.GetCell(8).CellStyle = titleCellStyle; headRow.GetCell(9).CellStyle = titleCellStyle; headRow.GetCell(10).CellStyle = titleCellStyle; headRow.GetCell(11).CellStyle = titleCellStyle; sheet.SetColumnWidth(0, 15 * 256); sheet.SetColumnWidth(1, 20 * 256); sheet.SetColumnWidth(2, 20 * 256); sheet.SetColumnWidth(3, 20 * 256); sheet.SetColumnWidth(4, 20 * 256); sheet.SetColumnWidth(5, 15 * 256); sheet.SetColumnWidth(6, 20 * 256); sheet.SetColumnWidth(7, 20 * 256); sheet.SetColumnWidth(8, 20 * 256); sheet.SetColumnWidth(9, 20 * 256); sheet.SetColumnWidth(10, 15 * 256); sheet.SetColumnWidth(11, 15 * 256); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { IRow row = sheet.CreateRow(i + 1); row.HeightInPoints = 22; row.CreateCell(0).SetCellValue(dt.Rows[i]["fin_oid"].ToString()); row.CreateCell(1).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["c_name"])); row.CreateCell(2).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["chk"])); row.CreateCell(3).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["na_name"]) + "/" + Utils.ObjectToStr(dt.Rows[i]["fin_detail"])); //row.CreateCell(4).SetCellValue(ConvertHelper.toDate(dt.Rows[i]["fin_sdate"]).Value.ToString("yyyy-MM-dd") +"/"+ConvertHelper.toDate(dt.Rows[i]["fin_edate"]).Value.ToString("yyyy-MM-dd")); row.CreateCell(4).SetCellValue(ConvertHelper.toDate(dt.Rows[i]["o_sdate"]).Value.ToString("yyyy-MM-dd") + "/" + ConvertHelper.toDate(dt.Rows[i]["o_edate"]).Value.ToString("yyyy-MM-dd")); row.CreateCell(5).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["fin_illustration"])); row.CreateCell(6).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["fin_expression"])); row.CreateCell(7).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["fin_money"])); row.CreateCell(8).SetCellValue(dt.Rows[i]["fin_area"].ToString()); row.CreateCell(9).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["fin_month"])); row.CreateCell(10).SetCellValue(dt.Rows[i]["fin_flag"].ToString() == "0" ? "待审批" : dt.Rows[i]["fin_flag"].ToString() == "1" ? "审批未通过" : "审批通过"); row.CreateCell(11).SetCellValue(dt.Rows[i]["fin_personName"].ToString()); row.GetCell(0).CellStyle = cellStyle; row.GetCell(1).CellStyle = cellStyle; row.GetCell(2).CellStyle = cellStyle; row.GetCell(3).CellStyle = cellStyle; row.GetCell(4).CellStyle = cellStyle; row.GetCell(5).CellStyle = cellStyle; row.GetCell(6).CellStyle = cellStyle; row.GetCell(7).CellStyle = cellStyle; row.GetCell(8).CellStyle = cellStyle; row.GetCell(9).CellStyle = cellStyle; row.GetCell(10).CellStyle = cellStyle; row.GetCell(11).CellStyle = cellStyle; } } MemoryStream file = new MemoryStream(); hssfworkbook.Write(file); HttpContext.Current.Response.BinaryWrite(file.GetBuffer()); HttpContext.Current.Response.End(); }