一、.Net Excel操作之NPOI,操作Excel单元格自动换行



HSSFWorkbook workbook = new HSSFWorkbook(); // 工作簿  ISheet sheet = workbook.CreateSheet("会员列表"); IRow notesInfo = sheet.CreateRow(1);                 notesInfo.Height = 15 * 200;//设置高度                 ICell notesTitle = notesInfo.CreateCell(0);                 ICellStyle notesStyle = workbook.CreateCellStyle();                 notesStyle.WrapText = true;//设置换行这个要先设置                 StringBuilder noteString = new StringBuilder("相关数据字典:(★★请严格按照相关格式填写,以免导入错误★★)\n");                 noteString.Append("1.列名带有' * '是必填列;\n");                 noteString.Append("2.会员卡号:会员卡号长度为3~20位,且只能数字或者英文字母;\n");                 noteString.Append("3.性别:填写“男”或者“女”;\n");                 noteString.Append("4.手机号码:只能是11位数字的标准手机号码;\n");                 noteString.Append("5.固定电话:最好填写为“区号+电话号码”,例:075529755361;\n");                 noteString.Append("6.会员生日:填写格式“年-月-日”,例:1990-12-27,没有则不填;\n");                 noteString.Append("7.会员等级:" + gradeResult + ";\n");                 notesStyle.WrapText = true;                 notesTitle.SetCellValue(noteString.ToString());                 notesTitle.CellStyle= notesStyle;//设置换行



展示结果:

.Net Excel操作之NPOI,操作Excel单元格自动换行_操作Excel单元格自动换行


更多:

​.Net Core NOPI操作word(二) 表格操作​

​.Net Core NOPI操作word(一)​

​.Net Excel操作之NPOI(二)常用操作封装​