+ 3

Can c# read an xl file

I want to write a program that will read lines from an xl file and ask the user if they want the record based on the city. If yes I want the code to grab all records with the city and write to a new file. I then want to have the city stored in a list file so as the program runs or the next time the program is run it will not ask you if you want records of cities you said yes to on previous runs of the program. After running the program a few times it should no longer need to ask if you want a city and read the cities from the city list created by yes answers. It should create the latest new file with all records with cities of interest. Question can c# open and read from an xl file? Can you give me an idea of how the code would look? I’m a beginner in c# but have programmed large applications in the past. thanks for pointing me in the right direction!

10th Oct 2019, 12:40 AM
Frank
4 Antworten
+ 6
Hi Frank. Are you talking about a .xl file that opens in Microsoft Excel or a .xml file?
10th Oct 2019, 2:24 AM
Jayden LeCorps
Jayden LeCorps - avatar
+ 2
Hi Jayden. An xl file that opens in excel. I want to be asked wether a city is of interest and if yes collect all lines in the file with that city and write tgem to another file. the program should only ask about a city it hasent asked about in the past. over time it should strip out all lines of data without having to ask about the city. i would need to run the program on excl files as they come in so it would not be the same file each time. the file structure may not be the same either so it would need to search for the city column each time it opened the excl file.
10th Oct 2019, 5:10 PM
Frank
0
с# can open Excel files if you mean them by using this “xl”. Take a look at EPPlus or Aspose Cells.
19th Oct 2019, 10:15 PM
Rustem Sharipov
Rustem Sharipov - avatar
0
Thank you Rustem. I saw a few good examples on youtube of opening, reading and writing xl files and sheets with c# using the microsoft.xl library. its s bit above my pay grade but I’m trying!
24th Oct 2019, 1:01 AM
Frank