【发布时间】:2011-02-24 21:46:40
【问题描述】:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Excel;
using System.Data;
namespace QuimizaReportes.Controllers
{
public class UploadController : Controller
{
public ActionResult Index()
{
//stream is supposed to be the excel file object.
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
excelReader.IsFirstRowAsColumnNames = true;
DataSet result = excelReader.AsDataSet();
while (excelReader.Read())
{
}
excelReader.Close();
return View();
}
}
}
我应该让用户上传文件并从中读取,然后显示一条确认消息,表明它已保存。问题是:我怎样才能“得到”那个流?有什么建议吗?
【问题讨论】:
-
这篇文章可能会有所帮助:stackoverflow.com/questions/1653469/…
-
@Ardman:我看不到他实际上传文件的位置。 [发布]操作在哪里?
-
@Sergio:看看cottsak的第三个代码块。
-
@Ardman:你是这个意思吗? FileManagerController.FileUploadResultDTO files = FileManagerController.GetFilesFromRequest((HttpContextWrapper)HttpContext); 我认为这是他制作的自定义类,但没有共享代码。是内置的吗?
-
@Sergio:您阅读完整答案了吗?他已经分享了代码。
标签: file-upload asp.net-mvc-3 stream