Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi,
I Know this sounds easy but I've tried and I've tried but i'm just stuck in the middle of no where so , I want to be able to read a large multiple excel files in a windows presentation foundation application and i can edit this files.

I can't make mind of which path to choose or what should i do i'm really stuck because solutions for windows forms doesn't work, most of the times , for wpf and it doesn't bring the best out the windows presentation foundation technology which i want to take advantage from it.

Thanks
Posted
Comments
[no name] 13-Aug-14 15:29pm    
And we are suppposed to be able to figure out what your actual problem is from this?
PIEBALDconsult 13-Aug-14 15:46pm    
Does it need to support only Excel 2007 and newer?
There are many articles here on CP that deal with reading and writing Excel files. Seek and you shall find.
Member 10743229 13-Aug-14 16:01pm    
@PiEBALDconsult
No it has to support not only excel 2007 and the excel files are large and multiple files.
@Wes Aday
You can be much nicer to people, you were once a student and a beginner !!!
Sergey Alexandrovich Kryukov 13-Aug-14 16:12pm    
No. Wes Aday does not have to be nicer; how about yourself?
He is asking you quite a legitimate question, not trying to hurt you at all, but with the purpose of helping you, which is also possible if you properly clarify your question. Instead of trying to improve your question, you are trying to distract discussion into imaginary offense. If you want to play offense card, how can you learn anything from people?

As to the "beginners": the beginner is the one who begins, not the one who looks for excuses. Don't get me wrong: I am not saying that you are doing something wrong, I just say that being a beginner is a very usual thing and does not give people any special status. Not only we all remember well how to be a beginner, we really help many beginner and most of us are still beginner, maybe in some different fields: when my horse riding trainer tells me that I'm treating the horse incorrectly, I don't say "be nicer", I try my best to treat the horse correctly. Can you see the difference?

—SA
Member 10743229 13-Aug-14 16:23pm    
Don't get me wrong, but i've looked around and around and i don't wantto play the offense card, and i don't want any special treatment but just try to not hurt people's feelings.
You shouldn't get mad,try to be in my shoes.I've learned so many thing about and from people.It's about problem that i'm seeking your help andi'm sorry if anyone get hurted by me.

It is not related to WPF, as I already noted in my comment to the question. Three most usual approaches are: 1) using Office interop assembly, 2) using Open XML SDK, 3) using 3rd-party products, mostly based on Open XML standard and directly forming the file of .xslx data structure.

I would recommend using Open XML SDK. Please see my past answers referenced in this on: How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010[^].

See also this answer by Mika Wendelius, CodeProject member: Creating basic Excel workbook with Open XML[^].

Please see Microsoft warnings against using interop assemblies in certain settings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

Good luck,
—SA
 
Share this answer
 
Comments
Andreas Gieriet 13-Aug-14 16:46pm    
My 5 for the hints and all the references. I still think the OP has unclear requirements/expectations, though.
Cheers
Andi
Sergey Alexandrovich Kryukov 13-Aug-14 16:54pm    
Thank you, Andi.
Well, unclear requirements are common; everything can be clarified in few iteration of the discussion. It's only bad when it causes too much of wasted efforts. Hope this is not the case. :-)
—SA
Maciej Los 13-Aug-14 16:47pm    
Yeah, you're right, Sergey. 5ed!
Sergey Alexandrovich Kryukov 13-Aug-14 16:52pm    
Thank you, Maciej.
—SA
Fire up Excel and let Excel do the work?
Why emulating all the filtering, sorting, formula editing, etc. in a wpf application?

Or use a commertially available component for reading and writing the *files*, like http://www.tmssoftware.com/site/flexcelnet.asp[^] and only provide a simple grid editor.

We have no clue what your *real* requirements are - depending on your requirements, you open up the box of Pandora or it's a simple solution (or somethin in between).

E.g. do you want the full feature set from Excel, like all editing and error handling, all graphics capabilities, all relations and multi sheets, etc. etc.? Or do you just want to enter some data in a data grid, no sorting, no graphics, no filtering, no fancy stuff?

Cheers
Andi

PS: And please stop "whining". You do not show us any of your effort. This is not the place for "gimme solution". No obvious effort from your side usually does result in no answer.
 
Share this answer
 
v2
Comments
Member 10743229 13-Aug-14 16:36pm    
I have a wpf application and multiple large excel files: At runtime ,i want to be able to read this excel files just like in MS-Excel(whatever the version of the MS-Excel is)and i'll be able to edit the files by another window(that pop'sup like settings thing).
Andreas Gieriet 13-Aug-14 16:40pm    
Editing may mean many things: only cell text, or formulas and let them evaluate directly or create/modify graphics, or re-arrange columns and cells, have print ranges defined, etc.? What do you really need?
Sergey Alexandrovich Kryukov 13-Aug-14 16:43pm    
Good points, a 5. I agree with you. Nevertheless, I posted some recommendation on writing Excel documents in Solution 2, please see. I also put a comment to the question, arguing on the OP's accusations against Wes Aday.
I agree with your advice on stopping whining, but you can expect some more unhappy response.. :-)
—SA
Andreas Gieriet 13-Aug-14 16:49pm    
Thanks for your 5, Sergey!
Member 10743229 13-Aug-14 16:47pm    
By editing i mean adding new rows that contains the settings data and deleting rows.
Well i have used the ado.net solution and i've tried to make it work for the wpf:
C#
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;
               Data Source=D:\TestData.xls;Extended Properties=""Excel 12.0;HDR=YES;""";


            string strSQL = "SELECT * FROM [Launch ClickPad$]";

            OleDbConnection excelConnection = new OleDbConnection(connectionString);
            excelConnection.Open(); 

            OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);

           
            DataTable dTable = new DataTable();
            dataAdapter.Fill(dTable);
            
            
            dataGrid1.DataContext = dTable;
           
           
            dTable.Dispose();
            dataAdapter.Dispose();
            dbCommand.Dispose();

            excelConnection.Close();
            excelConnection.Dispose();*/


So this displays empty rows i don't know what the problem is ?? or what am i doing wrong
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900