/// <summary> /// 导出意见 /// </summary> private void ExportSuggestionInfo(HttpContext context, string id) { var exXls = new ExportXls(); var fieldsNames = new List<string>(); fieldsNames.Add("学员姓名"); fieldsNames.Add("建议"); var quesBll = new BLL.Questionnaire(); var ds = quesBll.GetSuggestion(id); var courseBll = new BLL.Course(); var courseModel = courseBll.GetModel(new Guid(id)); var filename = courseModel.CourseName + "--学员建议.xls"; if (ds != null && ds.Tables.Count > 0) { exXls.ExportToXls(context.Response, fieldsNames, ds.Tables[0], filename); } }
/// <summary> /// 提取意见列表 /// </summary> /// <param name="context"></param> private void GetSuggestions(HttpContext context) { var ds = new DataSet(); var courBll = new BLL.Course(); ds = courBll.GetAllList(); var courseId = context.Request["coId"]; if (!string.IsNullOrEmpty(courseId)) { var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var questionbll = new BLL.Questionnaire(); var num = questionbll.GetSuggestion(courseId) == null ? 0 : questionbll.GetSuggestion(courseId).Tables[0].Rows.Count; ds = questionbll.GetSuggestionByPage(courseId, "", startIndex, endIndex); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); context.Response.Write(str); } }
private void GetSuggestion(string coid) { ISheet sheet2 = hssfworkbook.CreateSheet("学员建议"); ICellStyle cellstyleHead = hssfworkbook.CreateCellStyle(); cellstyleHead.VerticalAlignment = VerticalAlignment.Center; //表头样式 cellstyleHead.BorderBottom = BorderStyle.Thin; cellstyleHead.BorderLeft = BorderStyle.Thin; cellstyleHead.BorderRight = BorderStyle.Thin; cellstyleHead.BorderTop = BorderStyle.Thin; cellstyleHead.Alignment= HorizontalAlignment.Center; cellstyleHead.WrapText = true; var font = hssfworkbook.CreateFont(); font.FontHeightInPoints = 15; font.FontName = "宋体"; font.Boldweight = 700; cellstyleHead.SetFont(font); //表体样式 ICellStyle cellstyleContent = hssfworkbook.CreateCellStyle(); cellstyleContent.BorderBottom = BorderStyle.Thin; cellstyleContent.BorderLeft = BorderStyle.Thin; cellstyleContent.BorderRight = BorderStyle.Thin; cellstyleContent.BorderTop = BorderStyle.Thin; var font1 = hssfworkbook.CreateFont(); font1.FontHeightInPoints = 14; font1.FontName = "宋体"; font1.Boldweight = 10; cellstyleContent.SetFont(font1); cellstyleContent.WrapText = true; sheet2.SetColumnWidth(0, 13 * 256); sheet2.SetColumnWidth(1, 78 * 256); IRow title0 = sheet2.CreateRow(0); title0.Height = 600; for (int f = 0; f < 2; f++) { ICell cell = title0.CreateCell(f); cell.SetCellValue("学员建议"); cell.CellStyle = cellstyleHead; } SetCellRangeAddress(sheet2, 0, 0, 0, 1); var fieldsName = new List<string>() { "学员姓名", "建议" }; IRow title = sheet2.CreateRow(1); for (int f = 0; f < fieldsName.Count; f++) { ICell cell = title.CreateCell(f); cell.SetCellValue(fieldsName[f]); cell.CellStyle = cellstyleHead; } var quesBll = new BLL.Questionnaire(); var ds = quesBll.GetSuggestion(coid); var exportDs = ds.Tables[0]; int i = 2; if (exportDs != null && exportDs.Rows.Count > 0) { foreach (DataRow r in exportDs.Rows) { IRow row = sheet2.CreateRow(i); for (var j = 0; j < exportDs.Columns.Count; j++) { ICell cell = row.CreateCell(j); cell.CellStyle = cellstyleContent; cell.SetCellValue(Convert.ToString(r[j])); } i++; } } }