How to import multiple Excel worksheets into one datagridview?

Pengfei Liu 21 Reputation points
2021-07-12T04:11:28.07+00:00

I am using C# to build a WinForm application. I would import the data from a Excel file, which has multiple worksheets. Those worksheets has different rows and different columns. I want to allow the user to select multiple worksheets and import them into a datagridview. So the user has the ability to fix the errors in the data. After that, the code could do the job using the correct data.

Now I can import one worksheet using Oledb. What I learn is Oledb does work with multiple worksheets if the worksheets have different 'structure' (different columns). Is there any other approach to achieve my goal? Thanks.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,161 questions
{count} votes