如何导出到Excel文件FileHelpers [英] How to export to excel file with FileHelpers

查看:238
本文介绍了如何导出到Excel文件FileHelpers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用,我不知道该如何把我的数据并将其导出到文件助手一个Excel文件。

我看到一个教程提取记录而不是创建一个Excel文件。

我试图做到这一点

  ExcelStorage商=新ExcelStorage(typeof运算(图));

provider.StartRow = 2;
provider.StartColumn = 1;

provider.FileName =Customers.xls;

provider.HeaderRows = 6;

provider.InsertRecords(imgs.ToArray()); // IMGS是以前的列表
 

  

System.IO.FileNotFoundException是未处理由用户code
  消息=无法加载文件或程序集Interop.Excel,   版本= 1.3.0.0,文化=中性公钥= 3e0c08d59cc3d657或   它的一个依赖。该系统找不到指定的文件。
  来源= FileHelpers.ExcelStorage文件名= Interop.Excel,   版本= 1.3.0.0,文化=中性公钥= 3e0c08d59cc3d657
  FusionLog ==== pre-绑定状态信息===日志:用户= LOG:   显示名称= Interop.Excel,版本= 1.3.0.0,文化=中立,   公钥= 3e0c08d59cc3d657(完全指定的)日志:应用平台=   LOG:初始PrivatePath =调用汇编:   FileHelpers.ExcelStorage,版本= 2.9.9.0,文化=中立,   公钥= 3e0c08d59cc3d657。   ===日志:此绑定从default加载上下文。日志:正在使用应用程序配置文件:web.config中LOG:使用主机   配置文件:LOG:使用计算机配置文件   machine.config中。日志:后政策参考:Interop.Excel,   版本= 1.3.0.0,文化=中性公钥= 3e0c08d59cc3d657日志:   尝试新的URL文件下载:LOG:尝试新的下载   URL文件:Interop.Excel.DLL。日志:新的URL试图下载   文件:Interop.Excel.DLL。日志:新的URL试图下载   文件:Interop.Excel.DLL。日志:新的URL试图下载   文件:Interop.Excel.EXE。日志:新的URL试图下载   文件:Interop.Excel.EXE。日志:新的URL试图下载   文件:Interop.Excel.EXE。日志:新的URL试图下载   文件:Interop.Excel.EXE

     

堆栈跟踪:          在FileHelpers.DataLink.ExcelStorage.InitExcel()          在FileHelpers.DataLink.ExcelStorage.InsertRecords(对象[]记录)          在指数()的Controller.cs:行37          在lambda_method(封闭,ControllerBase,对象[])          在System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,对象[]参数)          在System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext   controllerContext,IDictionary的 2参数)          在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext   controllerContext,ActionDescriptor actionDescriptor,IDictionary的 2   参数)          在System.Web.Mvc.ControllerActionInvoker<> C_的 DisplayClass15.b 的_12()          在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter   过滤器,ActionExecutingContext preContext,Func`1续)
  的InnerException:

解决方案

我觉得你只需要添加一个引用到Excel组件在您的项目 - 这是一个依赖于你使用它导出到Excel软件。你可以找到COM选项卡下的组件,并且这里是一个链接,列出他们这样你就可以找到他们。您可能没有相同版本的链接,但他们将被命名为相对一致的。

让我知道如果你需要更多的帮助。

I am using File Helpers and I am unsure how to take my data and export it to an excel file.

I see a tutorial forextracting records but not creating a excel file.

I tried to do this

ExcelStorage provider = new ExcelStorage(typeof(Img));

provider.StartRow = 2;
provider.StartColumn = 1;

provider.FileName = "Customers.xls";

provider.HeaderRows = 6;

provider.InsertRecords(imgs.ToArray()); // imgs was a list before

System.IO.FileNotFoundException was unhandled by user code
Message=Could not load file or assembly 'Interop.Excel, Version=1.3.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657' or one of its dependencies. The system cannot find the file specified.
Source=FileHelpers.ExcelStorage FileName=Interop.Excel, Version=1.3.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657
FusionLog==== Pre-bind state information === LOG: User = LOG: DisplayName = Interop.Excel, Version=1.3.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657 (Fully-specified) LOG: Appbase = LOG: Initial PrivatePath = Calling assembly : FileHelpers.ExcelStorage, Version=2.9.9.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657. === LOG: This bind starts in default load context. LOG: Using application configuration file: web.config LOG: Using host configuration file: LOG: Using machine configuration file from machine.config. LOG: Post-policy reference: Interop.Excel, Version=1.3.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657 LOG: Attempting download of new URL file: LOG: Attempting download of new URL file:Interop.Excel.DLL. LOG: Attempting download of new URL file:Interop.Excel.DLL. LOG: Attempting download of new URL file:Interop.Excel.DLL. LOG: Attempting download of new URL file:Interop.Excel.EXE. LOG: Attempting download of new URL file:Interop.Excel.EXE. LOG: Attempting download of new URL file:Interop.Excel.EXE. LOG: Attempting download of new URL file:Interop.Excel.EXE.

StackTrace: at FileHelpers.DataLink.ExcelStorage.InitExcel() at FileHelpers.DataLink.ExcelStorage.InsertRecords(Object[] records) at Index() in Controller.cs:line 37 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c_DisplayClass15.b_12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException:

解决方案

I think you just need to add a reference to the Excel assembly in your project - it's a dependency for the software you're using to export it to Excel. You can find those assemblies under the COM tab, and here is a link that lists their names so you can find them. You may not have the same version as that link but they'll be named relatively the same.

Let me know if you need more help.

这篇关于如何导出到Excel文件FileHelpers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆