使用FileHelpers,如何从上传的Excel文件中提取logging

FileHelpers的一个捆绑示例显示了如何从/向Microsoft Excel工作表中提取和插入logging,如下所示:

使用与inputExcel文件中的列对应的成员定义一个类

[DelimitedRecord("|")] public class CustomersVerticalBar { public string CustomerID; public string CompanyName; public string ContactName; public string ContactTitle; public string Address; public string City; public string Country; } 

然后使用ExcelDataStorage提取logging如下:

 ExcelStorage provider = new ExcelStorage(typeof(CustomersVerticalBar)); provider.StartRow = 3; provider.StartColumn = 2; provider.FileName = "Customers.xls"; CustomerVerticalBar[] res = (CustomerVerticalBar[]) provider.ExtractRecords(); 

问题是,如果没有inputExcel文件,但input只能从上传的文件(例如HttpPostedFileBase)中作为inputstream使用,那么ExcelDataStorage只将文件名作为input,而不是input文件名inputstream? 如果解决scheme使用ExcelDataStorage以外的其他类,那么也行。

你应该把它写入一个文件,然后在处理之后删除它,因为这个库可能需要加载一些数据而不是全部,而且可能需要多次引用这个文件。