Epplus 设置excel 页边距 及多文件合并
2016-03-30 16:10
375 查看
1:使用epplus合并多个excel文件到同一excel的不同sheet页中
2:设置excel文件sheet页的 页边距(使用epplus)
private static bool MergeExcel(string _stFilePath, List<string> _listFiles, string _stSaveFileName) { ExcelPackage epMergeFile = new ExcelPackage(); bool result = true; try { string stSheetName = string.Empty; foreach (string item in _listFiles) { if (!FileIsHave(_stFilePath + "\\" + item)) continue; FileInfo newFile = new FileInfo(_stFilePath + "\\" + item); //开启 using (ExcelPackage pck = new ExcelPackage(newFile)) { //设定ExcelWorkBook ExcelWorkbook workBook = pck.Workbook; if (workBook != null) { if (workBook.Worksheets.Count > 0) { //设置excel表格的页边距 //workBook.Worksheets[1].PrinterSettings.TopMargin = 10M / 2.54M; stSheetName = item.Substring(0, item.LastIndexOf('.')); epMergeFile.Workbook.Worksheets.Add(stSheetName, workBook.Worksheets[1]); } } } } } catch (Exception ex) { result = false; Debug.WriteLine("合并文件失败:" + ex.Message); throw new Exception("合并文件失败!"); } if (result) { string stFile = _stFilePath + "\\" + _stSaveFileName; epMergeFile.SaveAs(new FileInfo(stFile)); epMergeFile.Dispose(); } return result; }
2:设置excel文件sheet页的 页边距(使用epplus)
相关文章推荐
- 内置对象的相互转化
- HDU 3038 带权并查集判错(详解)
- 判断Android 系统是MIUI 的,魅族的Flyme ,还是原生的?
- android studio加载 so文件以及出错。android java.lang.UnsatisfiedLinkError: 分析及解决方法
- AS3.0 ByteArray详解
- Android AndBase框架实现多功能标题栏(一)
- 关于tornado的国际化遇到的问题记录
- ios UITableView性能优化
- Linux Shell常用技巧(二) grep
- shell中几种括号的结构和变量替换
- Js 解析Json
- jquery实现一个简单的表单验证实例
- ITOO5.0项目解题集锦一
- 改造间隙扯淡1:机器人产品
- Java并发编程:volatile关键字解析
- Java 使用软引用有效避免OOM 问题
- MYSQL的内外连接
- Intellij Idea 创建Web项目入门(一)
- mysql的存储引擎与锁
- 2023