C# Class Cedar.Framework.Common.BaseClasses.ExcelHelper

Excel辅助类
Show file Open project: Chinaccn/surfboard

Public Methods

Method Description
ReadExcelToDataSet ( string excelPath ) : DataSet

将Excel转成DataSet

ReadExcelToDataSet ( string excelPath, bool existheader, int top = null ) : DataSet

将Excel转成DataSet

WriteExcel ( DataSet set, bool addheader ) : void

导出Excel

WriteExcel ( DataSet set, string title, bool addheader, string extInfo = "", bool addPic = false ) : void

写入Excel

WriteExcel ( string json, bool addheader = true, string sheetName = "" ) : void

生成Excel

WriteExcel ( string json, string title, bool addheader, string extInfo = "", bool addPic = false, string alignJson = "", string sheetName = "table1", string alignName = "table2" ) : void

Json保存成Excel

WriteExcel ( string datalocation, string json, string title, string headerJson, string extInfo = "", bool addPic = false, string alignJson = "", string sheetName = "table1", string alignName = "table2" ) : void

Json保存成Excel

WriteSpecialExcel ( string datalocation, DataSet set, string title, string headerJson, string extInfo = "", bool addPic = false ) : void

写入Excel

Private Methods

Method Description
AddDataTable ( OfficeOpenXml.ExcelWorksheet worksheet ) : DataTable

根据sheet名称生成DataTable

AddExtInfo ( OfficeOpenXml.ExcelWorksheet worksheet, string info ) : void

添加时间

AddPic ( OfficeOpenXml.ExcelWorksheet worksheet ) : void

添加图片到Excel

AddRow ( OfficeOpenXml.ExcelWorksheet worksheet, DataTable dt, bool existheader, int top ) : void

添加数据行

AddSheet ( ExcelPackage package, string name ) : OfficeOpenXml.ExcelWorksheet

添加Sheet

AddTitle ( OfficeOpenXml.ExcelWorksheet worksheet, string title ) : void

添加表头

ReadXlsx ( string path, bool header, int top ) : DataSet

读取Excel2007

SetWorksheetBorder ( System.Drawing.ColorConverter wcc, OfficeOpenXml.ExcelRange rangeArea ) : void

生成图文excel报表

设置边框

Method Details

ReadExcelToDataSet() public static method

将Excel转成DataSet
public static ReadExcelToDataSet ( string excelPath ) : DataSet
excelPath string
return System.Data.DataSet

ReadExcelToDataSet() public static method

将Excel转成DataSet
public static ReadExcelToDataSet ( string excelPath, bool existheader, int top = null ) : DataSet
excelPath string excelPath(String)
existheader bool 是否有表头
top int 取多少行
return System.Data.DataSet

WriteExcel() public method

导出Excel
public WriteExcel ( DataSet set, bool addheader ) : void
set System.Data.DataSet 数据源
addheader bool 是否添加列头
return void

WriteExcel() public method

写入Excel
public WriteExcel ( DataSet set, string title, bool addheader, string extInfo = "", bool addPic = false ) : void
set System.Data.DataSet 数据源
title string 表头
addheader bool 是否需要添加标题
extInfo string 信息
addPic bool 是否添加图片
return void

WriteExcel() public method

生成Excel
public WriteExcel ( string json, bool addheader = true, string sheetName = "" ) : void
json string 数据
addheader bool 是否添加列头
sheetName string sheet名称
return void

WriteExcel() public method

Json保存成Excel
public WriteExcel ( string json, string title, bool addheader, string extInfo = "", bool addPic = false, string alignJson = "", string sheetName = "table1", string alignName = "table2" ) : void
json string Json字符串
title string 表头
addheader bool 是否添加列头
extInfo string 扩展信息
addPic bool 是否添加图片
alignJson string 列对齐方式
sheetName string Name of the sheet.
alignName string Name of the align.
return void

WriteExcel() public method

Json保存成Excel
public WriteExcel ( string datalocation, string json, string title, string headerJson, string extInfo = "", bool addPic = false, string alignJson = "", string sheetName = "table1", string alignName = "table2" ) : void
datalocation string datalocation(String)
json string Json字符串
title string 表头
headerJson string headerJson(String)
extInfo string 扩展信息
addPic bool 是否添加图片
alignJson string 列对齐方式
sheetName string Name of the sheet.
alignName string Name of the align.
return void

WriteSpecialExcel() public method

写入Excel
public WriteSpecialExcel ( string datalocation, DataSet set, string title, string headerJson, string extInfo = "", bool addPic = false ) : void
datalocation string 数据加载位置
set System.Data.DataSet 数据源
title string 表头
headerJson string headerJson(String)
extInfo string 信息
addPic bool 是否添加图片
return void