将excel导入到datatable ,并修改列名
/// <summary>
/// 将excel导入到datatable
/// </summary>
/// <param name="fs">Stream文件流</param>
/// <param name="isColumnName">第一行是否是列名</param>
/// <param name="isReplace">是否替换表头</param>
/// <returns>返回datatable</returns>
public static DataTable ExcelToDataTable(this Stream fs, bool isColumnName = true, Dictionary<string, string> list = null, bool isReplace = false)
{
DataTable dataTable = null;
DataColumn column = null;
DataRow dataRow = null;
IWorkbook workbook = null;
ISheet sheet = null;
IRow row = null;
ICell cell = null;
int startRow = 0;
try
{
workbook = new HSSFWorkbook(fs);
if (workbook != null)
{
sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
dataTable = new DataTable();
if (sheet != null)
{
int rowCount = sheet.LastRowNum;//总行数
if (rowCount > 0)
{
IRow firstRow = sheet.GetRow(0);//第一行
int cellCount = firstRow.LastCellNum;//列数
//构建datatable的列
if (isColumnName)
{
start