Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have an excel file containing different sheets. In my first form ,I need to import the excel and get data from the first sheet and in other 2 forms I need to import the same file and work with the other sheets.

Can someone help me to avoid importing the excel file multiple times.

What I have tried:

I want to import the file only once and i got the idea to get the combobox having the sheet name and clone it in the other forms.
Posted
Comments
Richard MacCutchan 12-Jan-21 9:57am    
It depends how you are importing it and where you store it. But you could always import all the sheets at the beginning of your program and then pass the specific parts to your sub forms as required.
houssem eddine ayari 12-Jan-21 10:05am    
I import the file using openfiledialog and read it with IExcelDataReader and then in my combobox i choose the sheet. Later I visualize the data in my datagridview and save it in SQL database. How to import all the sheets and pass the sheet which i need to work with in each form ?
Richard MacCutchan 12-Jan-21 10:32am    
OpenFileDialog has nothing to d with this issue, that just allows your user to select a filename. I have not heard of IExcelDataReader so cannot advise you on its use.
[no name] 12-Jan-21 9:59am    
Create a public static collection of the data.

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