Easiest way to output an entire database table into an Excel file? - c#

I have a table called Products in my database. It has a couple of attributes, but nothing complex.
This is on a ASP.Net MVC3 application using Entity Framework 4 for data access, and I just want to create an ActionMethod that returns a downloadable (generated on request) excel file containing all the data inside the table.
What is the simplest way to generate an excel file from data in a table?
I'm using .NET 4, so the latest technologies/options are available to me.

I agree with xanadont's comment (csv is easier), but if you're using EF (probably, but not specified) and need to export an excel file this will do this trick:
http://rachel53461.wordpress.com/2011/06/26/exporting-a-view-or-stored-procedure-to-excel-with-entity-framework/

Related

Importing a MS-Project mpp file into C# .Net Framework and exporting the data into an SQLite database using MPXJ

**
Hello
**
I'm creating a scheduling app that takes in 2 MS-Project .mpp files (master and updated) and converts the data into SQLite tables then compares them both and displays the results and allows you to write the changes you make back to the master file. I had issues with Microsoft Interop because I don't own Microsoft Project. Is MPXJ a viable solution? The documentation I've read on it doesn't have many examples. If so how would I read it in and read it back? Were using MS-project 2016
I know nothing of MPXJ, so sorry if I overlook a more straightforward answer. It sounds to me like another way of looking at your problem is you want to:
1. Parse a MS Project file (and then do it again) and store results in memory
2. Do some data manipulation and calculations of the in-memory project data
3. Put that data into a database
I think you're stuck at step 1 because without MS Project, you lack a parser; correct? There are other ways to parse a project file. The simplest may be to have your users first convert the files to a more open format (e.g. XML) when they save them from their instances of MS Project. Lacking that, there are certainly libraries out there that can parse a Project file. Try taking a look at Gantt Project, https://sourceforge.net/projects/ganttproject/ . Being open source, you could look at that parser as a starting point; I'm not a license expert, but you may even be able to re-use the code from there.
Good luck!

Export SQL server data into a CSV file

I've just taken care of a project that requires converting data from the old website (built in C# web form) to the new one (using PHP).
In the old database, there is a product table contains 1600 products that I need to export into a CSV file then import to the new database but I have no idea to do that.
I can access the current server but I don't see any .cs file (code-behind file). I also have no idea how to export that table to a CSV file using myLittleTools (The SQL server management tool that Plesk provide).
Can any have me please?
Thank you very much.
Try SQL Server Import and Export Wizard. This is a tool provided by MSSQL .
Reference links here:
https://learn.microsoft.com/en-us/sql/integration-services/import-export-data/import-and-export-data-with-the-sql-server-import-and-export-wizard
https://learn.microsoft.com/en-us/sql/integration-services/import-export-data/get-started-with-this-simple-example-of-the-import-and-export-wizard
You can export to either or excel or directly map two tables of different databases and transfer data
According to the MyLittleAdmin site you can opent the table to view the data and export it form there.

Read excel file into database using mvc3 and stored procedure and without using any driver(Ace/Jet) and without EPPlus dlls

I have a requirement to upload and read an excel file into the database using a stored procedure but i can not use any external dlls like EPPlus or drivers like Jet/Ace. Can anyone help me to do this? I searched on so many sites but none met my requirements. This should be implemented in MVC 3. I have created the view. And the Browse option is working fine. All i need to know is how to upload and read.

Using SQL Bulk Copy to fill a database table

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

Writing to a PDF with fields from SQL Server 2005

I'm running an asp.net 4 / c# site using SQL Server 2005 and want to write column values from within SQL Server into a PDF file which already has content inside it (I want to personalise a PDF voucher that you get from the logged in page on my site)
Is there an easy tutorial to look at or is this a much bigger job?
There are two parts here:
Read data from database (for example, using ADO.NET, Entity Framework, e.t.c.)
Write that data to a PDF document (using some free or commercial PDF tool, like iTextSharp, SharpPDF, XPDF, Docotic.Pdf, e.t.c)
You can look at this article that describes both parts in detail.
Well, I think you have several options out there.
For example, you can create a PDF document based on a template using iTextSharp.
In that case, the template is the existing voucher you mention. You'd have to replace the information inside it, by identifying the fields, or something like that.
Something similar could also be accomplished using PDFSharp.
Just pay special attention when using iTextSharp to its license agreement, since its AGPL, which means your software must be GPL/AGPL as well.
Now, if you want to avoid interacting with PDF objects, and APIs, you have one other alternative. Which is to create an RDLC local report, and directly export it to PDF from your codebehind. In this case, it wouldn't be based on an existing voucher, it would be created from scratch.

Categories