Jump to content

File Reading

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
Hello everyone,

I'm a beginner level programmer for the most part. I want to do some things. Right now, I have a program that allows you to enter a "T-Number" (just a number that starts with T). So I have a textbox with Autocomplete showing all of the different T-Numbers. When you choose one, it will display different information about that T-Number, in my case, each T-Number has "Polarity", "Interface 1", "Interface 2" and "Notes". So when you choose a T-Number, those 4 things will show up on the form.

What I want to do...is to let the user have the ability to add new T-Numbers to the list and new data. Is there a way, to have an Excel file with all the T-Numbers and information laid out, so that if the user adds new data to the Excel Document, then the program would see that?

I want the T-Numbers to be in one column, then the information about it to be in the four cells to the right of the T-Number. Is this possible? Also, please remember that I'm a pretty low level programmer. So all explaining would be better for me and easier to understand. If you have any questions, just let me know. Thank you very much!!!

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Instead of letting the user open Excel and adding the T-Numbers you should develop an interface in your program that allows them to add the information they need. This method will allow you to check the data and make sure it is consistent and inserted into your file correctly.

#3
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
Okay, that is definitely something I can do. However, how can their new T-Number be saved for future use? Such as in the AutoComplete textbox and such? Thanks for the quick response.

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You have several options there. You can store it in a file (such as an excel/csv file), an INI file, an XML file, the registry or a database. Which method do you want to use? :)

#5
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
I think I'd like to store the information into Excel. That way it can be viewed later as well by the user and me. I think I know how to transfer what they type into the textbox transferred to Microsoft Excel, but how can I have it so that my program will get it's information from Excel?

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Now you are faced with another choice. If you use the Excel libraries I *believe* your users will need to have MS Office installed although I am not sure and stress the believe part. :)

You can learn how to read/write from Excel here: Reading & Writing Data into Excel - Query Tool to Excel using C# and .NET - developerFusion - the global developer community

You could also read/write to a .csv file. A csv file is a comma delimited file that will generally load in Excel as a spreadsheet if done properly. You could use a simple file reader/writer for this and I've wrote a tutorial on that here at CC:

http://forum.codecal...ding-files.html

And Xav wrote one on writing files:

http://forum.codecal...text-files.html

#7
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
Thanks Jordan, I'll definitely look into that. I believe that you're right about the users needing MS Office. I'm not concerned about that however. See, i'm only 18. I'm a co-op student attending Kettering University. I'm not sure if you know about Kettering, but there you do 3 months of schooling, then 3 months of work. So right now i'm on my first work-term. I return to school in January. I'm a freshman, so I've only had one school term, and only basic classes. So now I'm being employed by Emhart Teknologies, we're owned by Black & Decker. We deal with Stud Welding. My co-workers know that I'm still learning so many of the tasks that they give me are for learning. I'm barely benefiting the company, but this program that I'm working on, although simple, may actually help. Right now, they have a chart, with T-Numbers on it. They have to find the T-Number they're looking for on the chart, then to the right of it would be information regarding it. They're asking me to make a program to make their lives easier, by typing in the T-Number instead of looking it up on a confusing chart. So that's what I'm doing. Sorry for the long book, I type fast and sometimes get ahead of myself.

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
That sounds very neat! You should consider using a database instead since it is for a company. This will make it scalable for the future and easier for other developers to update. I would defiantly incorporate adding new T-Numbers from your program. In 3 months when you are gone the other people around you could leave as well then the knowledge of how to add new T-Numbers to a file might be lost and your program would be rendered useless. Just food for thought. :)

#9
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
Thanks for all of your help Jordan. I'm still learning a lot. When I started here (Oct. 1st), I had absolutely NO PROGRAMMING experience whatsoever! I've come quite a long way. My biggest accomplishments I think were taking company DataTables & DataGridViews and transferring them to Excel. I can also customize the format of the cells. Which is probably easy for most programmers, but it took quite some time for me to understand. I thought about using a Database, but I think my supervisor would rather me use Excel. He's been having me do lots with Excel lately, and I'd like to learn how to do it too. If he later decides I should use a database, then I'll take that step to learn that as well. Thanks again Jordan.

#10
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
The native Excel format, .xls, is complex and Excel-specific. You'd be better off with CSV files or a database.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#11
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
Thanks, but we're going to use the Microsoft Interoperability, not CSV.

#12
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
OK.

But a DB would still be the best thing!
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums