Displaying Tables from a document in a WPF application - c#

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.

Related

How to generate excel like report in WPF?

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.

opening sheet and selecting cells excel/c#

Hello I am looking for a way to open an Excel sheet programmatically and allow the user to be able to select a range of cells. My reasoning behind this is I am currently developing a lot of individual excel upload forms for pulling data in to a database I would like the ability to select the column headers as simply as highlighting the cells through excel and presenting a textbox for each to enter the equivalent DB table column name and store these. So effectively a form to create a form.
Many thanks
Charlie
Please check this article: Opening and Navigating Excel with C#.
There is also a section in MSDN library that completely covers Excel PIA.

Silverlight Datagrid to Excel export with cell formatting

Is there a way to do this in browser? (no AutomationFactory)
I know that I can export as CSV fine but I want to export my Silverlight datagrid as a Excel (.xls) document with the background colors of some rows set.
If you want to interact with MS Excel using Silverlight CLR - it is the only way to use AutomationFactory (becouse of silverlight pesmission restrictions). Ms Excel should be installed on client machines.
But you can also pass data to web-service, process it, and return excel sheet as byte array.
I suggest you use the second way.
I found this guide which is pretty much what I needed, although it is not elegant. Basically, loop through and print all the rows into XML format. I find it very strange that Microsoft would not provide an in-browser method to export to an Excel format and we need to do stuff like this
http://www.codeproject.com/Articles/45731/Export-Silverlight-DataGrid-to-Excel-XML-CSV
Export grid from silverlight to excel mht will work for any colors and formattings.

export to excel from sharepoint - complex

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

importing excel data while retaining formatting

Is it possible to import excel data to display using C# in any view(data grid etc ..) while retaining formatting like Bold, italic and strikethrough, throughout the document? I am making a Windows form application. My data is in an excel sheet, I want to display it in grid view or any other while retaining the formatting.
Well, there are some ways that I can think of but neither of them are very pretty at all and they would not be very effecient.
1) Parse the excel file cell by cell using Excel Interop. (Very nasty)
2) If you can convert the excel file to Excel XML you could then write say a XSLT to parse the file to pull styling data much more quickly.
Of course getting the styling data out is one thing. Applying it can be a whole other experience. Once you get the styling you have to make sure you apply the values to all the correct columns. Again very nasty and alot of parsing.
However since you did not say whether this was a web or desktop app you could always just embedd an excel control (on the web side) to display the data which may solve your problem. On a desktop app you are probably in for a world of pain trying to do what I describe above.
Maybe somebody will have a better answer but that's what I got.
SpreadsheetGear for .NET can load Excel workbooks and provides access to formatted text values as well as cell formatting such as fonts and colors.
SpreadsheetGear also comes with a Windows Forms spreadsheet control which will allow users to display, edit, format, calculate, print, etc... workbooks with formatting, charts, etc... intact.
If you are building an ASP.NET application, you can use SpreadsheetGear to open a workbook and generate an image of cells and / or charts as shown on our "Excel Chart and Range Imaging Samples" page here
You can download the free trial here if you want to try it out.
Disclaimer: I own SpreadsheetGear LLC

Categories

Resources