I have this Excel Sheet That I want to generate from my WPF Application, What is the easiest way to do so, bear in mind that the table in the sheet may have many containers and each container may have one or more sizes and so on as shown.
I'v looked at the ReportViewer provided in WPF but I don't know how to design such a report using the ReportViewer.
Another thing came to my mind is to fill the excel sheet from the WPF and I found a way to do so by specifying tags (Ex: Date: ) in which I can fill these tags from my WPF application, but I don't know who to generate tables and set their columns and rows according to the data in the database.
Thank you.
Did you try adding Microsoft.Office.Interop.Excel as a dll, and try the code given here.
Or have a look at this sample:
WPF Spreadsheet
I have made good experience with the EPPlus library. The nice thing is, you don't need any MS Office components on your OS to generate the excel files.
Related
I have been struggling the last few hours trying to get an excel spreadsheet/workbook to be displayed on a Windows form using Visual Studio 2012, C#. I can retrieve the data from the workbook and display it on the form, but I need the functionality of Excel in the application, including stuff like Filtering, Conditional Formatting, Formulas, etc.
I have read up quite a lot, and as I understand it, there are no controls in Visual Studio to embed these (Office) files due to licencing, which makes sense. I have found a solution though, to display the file in a WebControl (I am sure I will be able to work with this), but when I try to load the excel file in the web control, it prompts the user to either open or save the file, and when 'Open File' is chosen, the file is opened using Microsoft Excel.
As I understand it, this happens because the ContentType (Mime type, Excel ContentType) of the file needs to be set in the browser (I need to do more research on this as I am not yet familiar with this concept, ).
The resources I am using:
Logic to save the contents to an Excel File: EPPlus
I was working from the following project, among others: Winforms Excel Example
The latter is almost exactly what I want to achieve, but keeps on asking to save or open the file, rather than just displaying it in the WebControl
Any help on this matter would be greatly appreciated.
There're commercial WinForms libraries from DevExpress, Syncfusion and Infragistics. I'm using DevExpress. I'd suggest their WinForms Spreadsheet control inspired by Excel. They also have Spreadsheet File API for .NET and Spreadsheet UI controls for ASP.NET, MVC, WPF, ASP.NET Core and Bootstrap.
You can try their free 30-day trial and see if DevExpress UI controls suit your needs.
Use DataGridView and program a functionnality if it doesn't have it!
OR
Use Excel COM to create an instance of Excel.
I am working on a small application which reads through the word document and analyze it. The data present in the document are present in the form of tables ,Is there any way to display the data(tabular data) in the application..?
If DGV is the only solution for displaying a table ,Is there any way to bind the Interop table to Datagrid
I don't know if this would be the best approach but this is what I came up with right now. Google shows that there are many solutions to bind Excel to a DataGridView but hardly any for Word. In fact Stack Overflow also has many answers on converting Word to Excel.
Therefore, why not convert the Word contents to Excel and then bind the Excel contents to DGV? It's a roundabout way I know, but something is better than nothing. Here are some links that may help in this regard:
Programatically converting from MS word to Excel
Display excel file content in a Datagridview
http://www.dotneter.com/reading-excel-and-binding-to-datagridview-using-microsoft-office-interop-excel
Transferring data from Excel to dataGridView
If its just a matter of displaying then directly display the Word document in you WPF application.
Here, the link to achieve this.
There is some code/werbparts on our site that display a lot of data in a grid on our site. In addition, they have another page with a few charts.
I need a way to create functionality to export this to excel so the user can click a button and save everything.
The chart will actually have to be built in excel, I can't just grab the picture from the website and display it.
Also, the data from the grid will have to be put into a spreadhseet. I am not as worried about this part.
I have exported to excel before, but it was just basically printing some data which was tab delimited with a certain doc type .
This actually will need to use different work sheets and use some excel functionality.
(I need a better answer than use excel services)
Thanks!
Use Epplus is a third party library for creating and manipulating excel files(xlsx)
Dunno about sharepoint, but the OpenXML SDK might be what you're after:-
http://msdn.microsoft.com/en-us/library/bb448854.aspx
I have an excel spread sheet (well, hundreds of them) which I need importing into a database.
If the excel data was in a nice uniform format I would simply save them out to CSV, read them in using something like LINQ to CSV and save the required data away.
However, the excel spread sheet is 'uneven' in that different groups of cells contain different data.
I need a way of grabbing the data and then working with cell references to grab the bits I need and save them to the database.
What's the best way to achieve this?
Thanks
UPDATE some more information
I have numerous spread sheets, all identical in structure that need to be imported into a database. The import is not simple in that different chunks of data from the spread sheet will go into different tables. The excel document itself contains a few sections (basically question / answer) type data. For each different section I need to grab the data, shape it into a form that makes sense in terms of the database and save it.
Ideally I would like to create a quick little WPF app that will let me select a spread sheet hit a button and perform the import.
You could use the Excel Object Model to read the data if you do it in a non web environment.
See for example How to automate Microsoft Excel from Microsoft Visual C#.NET.
If it has to be inside a web application. I suggest to use Aspose Cells.
Turn the Excel Spread sheet into an ODBC (Open Database Connectivity) Data Source so you can access it just like you would any database:
http://www.datamystic.com/datapipe/excel_odbc.html
Then access it just like any database using ODBC:
http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcconnection(v=vs.71).aspx
When the data is not uniform, it is often better to keep your approach as simple as possible in the first instance. Start with vba and the "Range" object (which is part of the excel object heirarchy). From there you can increase the level of automation and in most instances reuse this "Range" work.
avariable = Range("A2:A5")
That notiation is not going to change very much. It wont matter what final target language you use (language: C# / vba / etc).
There are a number of other ways of going about this -- java based / xml based / c# based / and a few other really cool ones that only apply to certain niche situations. If you can provide more information about your use case, then perhaps I can suggest some more things to try.
Q & A
example link for automation from C#: http://support.microsoft.com/kb/302084
You should probably take a look at Microsoft's Visual Studio Tools For Office (VSTO), which handles a lot of the unpleasant COM/interop stuff for you.
To those who may be interested I ended up using LinqToExcel:
http://code.google.com/p/linqtoexcel/
Did exactly what I was after with minimal fuss. Excellent
Please show me the code how to import winforms controls, into excel xls. file.
I have created one winform in c#, but while taking print out c#,
there s no table border lines, because in c# winforms onle table layout tools s present, so i need to import this to excel and convert to table format and take print out.
thank u.... i expect the answer from your side...
I honestly don't really know what you're asking, but I'm going to take a guess that you want to host WinForms controls in an Excel workbook?
If so, you may find these MSDN articles useful:
How to: Add Windows Forms Controls to Office Documents
Using Windows Forms Controls on Excel Worksheets
Otherwise, you'll need to clarify your question and ask something a little more specific.