public ActionResult daoru(HttpPostedFileBase ExcFile)
{
HttpPostedFileBase file = Request.Files["ExcFile"];
Stream stre = file.InputStream;
HSSFWorkbook book = new HSSFWorkbook(stre);
ISheet sheet = book.GetSheetAt(0);
DataTable dt = new DataTable();
IRow row = sheet.GetRow(0);
int cellcount = row.LastCellNum;
int rowcount = sheet.LastRowNum;
for (int i = 0; i < cellcount; i++)
{
DataColumn column = new DataColumn(row.GetCell(i).StringCellValue);
dt.Columns.Add(column);
}
for (int i = 1; i < rowcount; i++)
{
IRow rows = sheet.GetRow(i);
DataRow datarow = dt.NewRow();
for (int j = 0; j < cellcount; j++)
{
datarow[j] = rows.GetCell(j);
}
dt.Rows.Add(datarow);
}
return View();
}