Export datatable to excel using LINQ or better way directly - c#

I dont want intermittent of using Gridview or Datagrid controls. I want directly to export a DataTable data to an Excel in straight forward.
Is there a way to export by querying the DataTable and export the same into a new Excel.
Please HELP!!

Take a look at this you can do it with XSLT
http://www.codedigest.com/Articles/ASPNET/13_Export_dataset_to_Excel_with_XSLT_in_AspNet_20.aspx

Related

Export to excel from linqDataSource in ASPX C#

How can export to excel all filtered data from a gridview witch has as datasource a linqdatasource?
I am using aspx c#
Use EPPLUS which provides a FromDataTable method.

update excel sheet without Header columns

I am working on read,write excel sheets.I have an excel sheet to update and unfortunately it does not have header columns.So I am stuck how to update this?
Is it possible to update excel sheet without header? If yes than plz help how to update?
thanks in advance
Try using excel data reader from Codeplex and check how it returns the data set. Also try to manipulate dataset based on your need

Entitydatasource to Datatable

I have a Gridview that reads the DataSource from an EntityDataSrouce.
Now I want to convert the EntityDatasource of the gridview to DataTable so I can export it the Gridview as an Excel file.
You do not need to convert it to DataTable just to export. You can do it by gridview self.
Look at this link:
http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html
In this article, the author uses a utility class that export it to .xls file, so, you can download it, add on your project and use like the sample.

OleDbAdapter reading column data

I have created a function to read an excel sheet using OLEDb. I can make the connection and read the excel sheet.
With DbDataReader and a while loop using Read() method I retrieved all cell data from an excel sheet.
I want to check the alignment info of each cell. If a cell is left-aligned, I will pick data from those left-aligned cells.
How can I do that?
Sorry It is a stupid question but I really need it.
Thanks
You can't do that with Excel OleDb provider; cell alignment isn't exposed. The OleDb provider makes the Excel spreadsheet mimic a database table and database columns don't have alignment.
You'll have to use Excel interop if you need to that. See this question for help on that.

Set Excel sheet as datasource to Gridview

I have the excel sheet, I want to keep it as datasource to the gridview. gridview will be editable so whatever the data updated sholud be write to again in excel sheet with respected location in sheet.
How can I do this?
You could use the Jet driver to select from the spreadsheet via OLEDB. Your spreadsheet will need to be laid out in a table-like fashion, and you can have some painful problems with type guessing, but this may work for your situation.
Connection string samples here

Categories

Resources