Export npoi from datatable

I have an asp.net site that will generate some excel files with 7-8 data sheets. Best NPOI solution so far , this can create excel files without having excel installed on the server, and has a nice API to interact with excel.

However, I cannot find a way to dump the complete datatable in excel like CopyFromRecordset

Any advice on how to do this, or a better solution than NPOI?

+2


a source to share


1 answer


I think NPOI is a good solution, you don't want to interact with Office in a server based environment like ASP.NET, it just isn't designed for that and it will fail. Actually MS doesn't support this, I am updating the link.

As far as NPOI goes, our team used it for something very similar, and I know they wrote a routine to dump data, so I'm guessing that means NPOI doesn't have this capability natively.

Basically you will need to list the values ​​in each row of the DataTable and write the out value, this should be a fairly simple procedure to write.

Refresh . The link I promised.



http://support.microsoft.com/kb/257757

Key phrase from the above link

Microsoft does not currently recommend or support the automation of Microsoft Office applications from any inactivity, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT services) as Office may exhibit erratic behavior and / or deadlock when Office is started in this environment.

+5


a source







All Articles