I'm working on an web app using ASP.NET MVC4. I have an Excel file with several columns (some of them are useless) and I'd like to export the data to a related table by uploading the file.
One of my superiors told me to use SQL Bulk Copy to do that. I search some information about that but nothing really interesting (for example, nothing about how to map the excel columns and the table fields).
Any idea/tutorial to do that?
Hello friend please review this article, i think it will contains all the required information you needed. but you need to do some modification as per your requirement.
SQLBulk insert from Excel
if you are facing any connection issue with your Excel workbook, please modified your excel connection string for that there is a good article provide all the necessary information regarding Excel connection string
Excel Connection String Sample
Related
I want to be able to send data from an excel file to an SQL database.
The Excel file only has one column and will always be this way.
I am currently working on a project where people will place excel files into a folder which will need to be read and put into sql, I am able to monitor the folder currently and am able to capture the file name of that file to a variable which i can call to select the excel file.
What i cannot find is a simple excel to sql tutorial that doesnt rely on the import wizard.
If you are able to help please do and if you want any further information please feel free to ask
Thanks alot :)
I need to read particular columns from an Excel sheet (say Columns A,P,Q,B) and also some particular cells (say C3 or D10). I do not need it to be displayed in a DataGrid view or anything (all examples I have seen use DataGrid).
How do I do that and write them into a new CSV file?
I have no sample code as I do not know how to proceed.
I sugest you use the ExcelReaderInterop library.
using Microsoft.Office.Interop.Excel;
Detailed example can be found here:
http://www.dotnetperls.com/excel
I had to deal with a similar issue a few weeks ago and could not find a simpler way to deal with this. The post suggest this overkill approach may be due to lots of legacy code in the library.
We have successfully used the Microsoft Access Database engine to open and read Excel files. The "2010 Access Redistributable" can also be installed on a server free of charge. What you asking for is a multi-step process:
Open a connection to the file using the Access OleDbConnection. In the connection string the "Data Source" is the file name.
Select the appropriate worksheet, which will return a DataTable object.
Grab a row from the data table or iterate over top of all of them myDataTable.Rows.
Access the column in question.
This post shows some of the process:
SSIS Excel Source Connection. What does it use to read Excel?
Hopefully this gets you pointed in the right direction.
I copied the columns that I needed to another excel sheet and saved it as CSV. Then read this csv to perform the task.
This was the easiest option as the machine I was suppose to run the program didn't have Microsoft office.
I have an Excel template which has dynamic rows and columns (it means the Excel template will be downloaded based on the parameters I select in my UI). Now there will be some data in the Excel sheet against those dynamic rows and columns coming from the database. I want to modify that Excel and import it so that only the updated(modified) cell values are updated in database. I thought a lot and I think this can be done with macros (by changing the color of cells with updated values and picking them up from C#). I would welcome any other thoughts/approaches for this.
An approach I have used is to create a webdav/REST service which can then be mounted as a drive in Windows.
The exposed file on the webdav service was simply a CSV, which users could edit in Excel, but the GET request was serviced by reading the database.
After making the changes, the user saved in Excel, which caused a PUT on the webdav service. The PUT request wrote the new values to the database.
I'm new to the ASP.NET world and need some help.
I need to create a GridView which shows the Employee's name. When a user clicks on the Employee Name, it will call the stored procedure to get particular details from the database and export the data into an excel sheet.
There are commercial and open sources libraries available to facilitate this task, but I am a fan of DoddleReport as it is easy to configure and use.
I wrote a blog post demonstrating how to use DoddleReport and PetaPoco to export a SQL Server PIVOT query from an ASP.NET MVC3 application to Excel. The Excel portion of the task is only a couple lines of code.
The sample project is available on github
I want to show information from an excel spreadsheet in a web page. The xls will have maybe 5 columns, and as many rows as needed. The columns will be 'Name', 'Created Date', 'Expired Date', 'Owner', and maybe down the road maybe more.
What I would like is for the C# to nightly read the xls, and display the information in a table on the website.
If there is a PDF available for download I am going to link that as well.
Thanks in advance,
Gene
Here is an article describing how to read an Excel file using the OLEDB data provider.
However, this probably needs to live in a service or its own executable and kicked off with a scheduled job to fill some tables that your web page looks at.