string filename = "test.xls"; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.Clear(); string reuslt = "0.8锌铁板制做烤漆字、食人鱼防水LED模组(三颗灯)、4mm厚黑白板(特殊材料,白天黑色,打灯后发白光) "; int splitnum = 25; int num = reuslt.Length; int rownum = num / splitnum + ((num % splitnum) > 0 ? 1 : 0); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet(); int rowIndex = 0; int cellIndex = 0; HSSFRow row = (HSSFRow)sheet.CreateRow(rowIndex); row.HeightInPoints = rownum * 17; HSSFCell cell = (HSSFCell)row.CreateCell(cellIndex); HSSFCellStyle style = (HSSFCellStyle)workbook.CreateCellStyle(); style.WrapText = true; string modify = ""; for (int i = 0; i < rownum; i++) { int start = splitnum * i; int leave = num%(num - start); modify+=(reuslt.Substring(start, leave == 0 ? splitnum : leave + 1) + " "); } cell.CellStyle = style; cell.SetCellValue(modify.TrimEnd(' ')); MemoryStream file = new MemoryStream(); workbook.Write(file); file.WriteTo(Response.OutputStream); Response.End();