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();
}
}
}
Je suis censé permettre aux utilisateurs de télécharger le fichier et de le lire, puis afficher un message de confirmation qu'il a été enregistré. La question est: Comment puis-je «obtenir» ce flux? Aucune suggestion?Comment puis-je lire un fichier téléchargé en utilisant MVC3?
Ce poste pourrait être utile: http://stackoverflow.com/questions/1653469/how-can-i-upload-a-file-and -save-it-to-a-stream-for-further-preview-using-c –
@Ardman: Je ne vois pas où il télécharge réellement le fichier. Où est l'action [Post]? –
@Sergio: Regardez le troisième bloc de code de cottsak. –