C
C#2y ago
Salakhosh

❔ How to import Excel File with row header to GridControl using C#. WPF application

Hello, can someone please help me write the code? I added a button that can browse and get path for excel file. The name of gridcontrol is Grids. And assume the code is written in button class
24 Replies
JakenVeina
JakenVeina2y ago
what is GridControl?
Salakhosh
SalakhoshOP2y ago
It’s a tool from DevExpress
JakenVeina
JakenVeina2y ago
then it looks like you'll want to use DevExpress' built-in support for Excel files? ExcelItemsSource?
Salakhosh
SalakhoshOP2y ago
Isn’t there a way to loop over excel file,add it to data table then bind it with GridControl?
JakenVeina
JakenVeina2y ago
sure, that sounds horrifying though, if DevExpress already does that whole thing for you you'd need to pull in an Excel parsing engine, like IronXL or OpenXML
Salakhosh
SalakhoshOP2y ago
Thing is idk what exactly the recruiter wants from me Like he told me here is an excel file import it to GridControl
JakenVeina
JakenVeina2y ago
then you probably want to go with the not-horrifying option
Salakhosh
SalakhoshOP2y ago
Idk if I should build the desktop over this specific file( in this case link you sent) or over any excel file( in this case we loop over it)
JakenVeina
JakenVeina2y ago
what does looping have to do with anything?
Salakhosh
SalakhoshOP2y ago
I mean go over excel file and add it to data table And then bind datatable to grid control
JakenVeina
JakenVeina2y ago
I.E. parse the file yourself don't do that if DevExpress can do it for you, that's silly
Salakhosh
SalakhoshOP2y ago
But according to link you sent it was manually specified the column headers
JakenVeina
JakenVeina2y ago
and I doubt he's expecting you tk hard-code the file either not true
Salakhosh
SalakhoshOP2y ago
JakenVeina
JakenVeina2y ago
yes, and?
Salakhosh
SalakhoshOP2y ago
He specified the columns of this specific excel file
JakenVeina
JakenVeina2y ago
and that's a requirement? that supercedes the snippet directly above that where an ExcelItemsSource is declared without any columns defined?
Salakhosh
SalakhoshOP2y ago
I didn’t get what you said
JakenVeina
JakenVeina2y ago
regardless If you've been instructed to use DevExpress, it seems like you should stick to that as much as possible I really have no idea how that works, specifically, the documentation is hilariously sparse, from what I can see. You either need to find more documentation, perhaps what came with your license, or start screwing around in code to see how it behaves.
Salakhosh
SalakhoshOP2y ago
Alright thank you
JakenVeina
JakenVeina2y ago
outside of DevExpress, it's what you say. You would parse all the rows out of the excel file yourself, and bind them into the GridControl, and for that you'll need a parsing library like IronXL or OpenXML
Salakhosh
SalakhoshOP2y ago
Kindly find attached the excel containing the data it should be imported into the database. We need a form to import this template to a DevExpress Grid Control and then save it to the database. You need the following tools to be installed on your PC: Visual studio
SQL server DevExpress Kindly note that you should create a WPF application using C#. this is the email that was sent
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server