当前位置: 首页 > news >正文

网站上怎样做下载文档链接wordpress 轮播图

网站上怎样做下载文档链接,wordpress 轮播图,软件项目管理总结,最好的装饰公司营销型网站NuGet中安装npoi 创建excel模板#xff0c;替换其中的内容生成新的excel文件。 例子中主要写了这四种情况#xff1a; 1、替换单个单元格内容#xff1b; 2、替换横向多个单元格#xff1b; 3、替换表格#xff1b; 4、单元格中插入图片#xff1b; using System.IO; …NuGet中安装npoi 创建excel模板替换其中的内容生成新的excel文件。 例子中主要写了这四种情况 1、替换单个单元格内容 2、替换横向多个单元格 3、替换表格 4、单元格中插入图片 using System.IO; using NPOI.XSSF.UserModel; using NPOI.SS.UserModel; using System.Diagnostics;public static void exportExcel(){string currentDirectory System.AppDomain.CurrentDomain.BaseDirectory;string templatePath currentDirectory /template.xlsx;string outputPath currentDirectory /output/ DateTime.Now.ToString(yyyyMMdd); //存储路径string outputPathExcel outputPath / DateTime.Now.ToString(yyyyMMddHHmmss) _test.xlsx;// 检查路径是否存在if (!Directory.Exists(outputPath)){Directory.CreateDirectory(outputPath);}//1、单元格直接替换部分Dictionarystring, string replacements new Dictionarystring, string{{ test1, 测试1 },{ test2, 测试2 }};//2、横向数组,曲线表格Dictionarystring, double[] replacementsArrayH new Dictionarystring, double[]();replacementsArrayH[item1] new double[] { 1.1, 2.2, 3.3 };replacementsArrayH[item2] new double[] { 4.4, 5.5, 6.6 };//3、表格数据//自己定义类//public TaskItem{// private string name;// private string age;// public TaskItem(){// }// public TaskItem(string name, string age){// this.namename;// this.ageage;// }// ……//}ListTaskItem taskItemList new ListTaskItem();taskItemList.Add(new TaskItem(Alice, 30));taskItemList.Add(new TaskItem(Bob, 25));try{// excel导出using (FileStream file new FileStream(templatePath, FileMode.Open, FileAccess.Read)){IWorkbook workbook new XSSFWorkbook(file);ISheet sheet workbook.GetSheetAt(0);// 替换模板中的字符串for (int rowIndex 0; rowIndex sheet.LastRowNum; rowIndex){IRow row sheet.GetRow(rowIndex);if (row null){continue;}for (int cellIndex 0; cellIndex row.LastCellNum; cellIndex){ICell cell row.GetCell(cellIndex);if (cell ! null cell.CellType CellType.String){string cellValue cell.StringCellValue;//填充单个文本foreach (var replacement in replacements){if (cellValue.Equals(replacement.Key)){cell.SetCellValue(cellValue.Replace(replacement.Key, replacement.Value));}}//填充横向数组foreach (var replacement in replacementsArrayH){string placeholder replacement.Key;double[] values replacement.Value;int index values.Length;if (cellValue.Equals(replacement.Key)){for (int colNum 0; colNum index; colNum){cell row.GetCell(cellIndex colNum);cell.SetCellValue(cellValue.Replace(placeholder, values[colNum].ToString()));}}}//填充详情表格if (cellValue.Equals(table)){if (list null) // list 为业务需要写入数据{continue;}// 添加数据行for (var i 0; i list.Count; i){TaskItem item list[i];// 因为模版内已经存在一格空行所以直接赋值后续从此行进行 CopyRow 即可if (i 0){SetRowCellValue(row, item, cellIndex);continue;}//其他行var newRow sheet.CopyRow(rowIndex, rowIndex i);SetRowCellValue(newRow, item, cellIndex);}}}}}//4、导出图片string picPath currentDirectory /test.png;//图片byte[] bytes File.ReadAllBytes(picPath);int pictureIndex workbook.AddPicture(bytes, PictureType.PNG);// 定义图片的位置var drawingPatriarch sheet.CreateDrawingPatriarch();var anchor drawingPatriarch.CreateAnchor(0, 0, 0, 0, 1, 6, 12, 13); // 参数依次是dx1, dy1, dx2, dy2, col1, row1, col2, row2// 在单元格中添加图片var picture drawingPatriarch.CreatePicture(anchor, pictureIndex);// 保存新文件using (FileStream outputFile new FileStream(outputPathExcel, FileMode.Create, FileAccess.Write)){workbook.Write(outputFile);}}}catch (Exception ex){}}/// summary/// 填充表格数据/// /summary/// param namerow填充行/param/// param nameitem填充数据/param/// param namecellIndex列开始行/paramprivate static void SetRowCellValue(IRow row, TaskItem item, int cellIndex){ICell cell row.GetCell(cellIndex);cell.SetCellValue(item.name);cellIndex;cell row.GetCell(cellIndex);cell.SetCellValue(item.age);} excel模板内容 导出后
http://www.w-s-a.com/news/525484/

相关文章:

  • 做的网站放在阿里云网站建设投标书范本
  • 做文化传播公司网站wordpress仿简书
  • 什么网站有题目做西宁网站制作哪里好
  • 网站上添加图片的原则优易主机 wordpress
  • 用php做的网站源代码那里有做像美团的网站的
  • 网站建设百科有什么做兼职的网站
  • 创造网站电商网站建设方案道客巴巴
  • 南通设计网站建设wordpress时光轴
  • 郑州做网站企起网站建设 风险
  • 北京市保障性住房建设投资中心网站6大连广告设计与制作公司
  • 建站之星网站模板国内f型网页布局的网站
  • 怎么做网站关键词优化外贸网站 开源
  • 广东公司响应式网站建设设计seo系统是什么
  • 清丰网站建设费用网站建设的前途
  • 网站上那些兼职网页怎么做的北京网页
  • 桂林建站平台哪家好品牌设计公司宣传文案
  • 平面设计和建设网站的区别公司官网静态
  • h5网站建设+案例住房住房和城乡建设部网站
  • 建设股公司网站东莞建设网网上平台
  • 湖州吴兴建设局网站加强网站建设的
  • 茌平做网站公司专业商城网站建设报价
  • 网站结构图怎么画wordpress注册不发送件
  • 个人备案网站可以做论坛吗电商推广方式有哪些
  • 网站建设 自适应国内最近的新闻
  • 校园网站开发背景吴江网站建设公司
  • 网站开发工程师发展趋势山东省建设工程电子信息网站
  • 适合大学生创业的网站建设类型吉林省舒兰市建设银行网站
  • 呼和浩特网站建设哪家好培训学校加盟费用
  • 网站如何做友情链接有道云笔记WordPress
  • 贵阳企业网站建设制作赤峰浩诚网站建设公司