Is it possible to convert a csv in excel to possibly a xls file?

jsalzm1

Member
Join Date
Jun 2015
Location
Houston
Posts
23
is it possible to convert a csv that is saved in excel to possibly a .xls or.txt file so I can read the values and insert it to a datagrid in a form?

the caputre pic is my code to save the file as a csv. the next pic is me trying to display the data onto datagrid..

Thanks

**note: the file that is in capture1.jpg works for a random file i saved as an .xls so I know the code works. The question is can the csv file, as seen as the one in caputre.jpg be converted to a .xls or something different

Capture.jpg capture1.jpg
 
Last edited:
In Excel, use the "text-to-colums" feature.
You will be asked which characters are to be interpreted as delimiters. Typically comma or semicomma.
edit: The above will only be necessary of Excel doesnt automatically convert into rows and columns.

Then use save-as to save as an .xls or .xlsx file.
 
Last edited:
is it possible to convert a csv that is saved in excel to possibly a .xls or.txt file so I can read the values and insert it to a datagrid in a form?

the caputre pic is my code to save the file as a csv. the next pic is me trying to display the data onto datagrid..

Thanks

**note: the file that is in capture1.jpg works for a random file i saved as an .xls so I know the code works. The question is can the csv file, as seen as the one in caputre.jpg be converted to a .xls or something different

Just open the CSV file in excel and then go to "save as" and at the bottom choose the file type you want to save it in, i.e. .xls
You should have no problems.
Eli
 
What do you mean? kinda new to vb and havent had a whole lot of experience with excel. Im just getting the feel for all the features excel has to offer
 
Ah, you want to save as .xls directly from VB code.
Didnt grasp that at first.

It IS possible, but why do that since you can open a CSV file in Excel no problems ?
Keep it simple.
 
Just open the CSV file in excel and then go to "save as" and at the bottom choose the file type you want to save it in, i.e. .xls
You should have no problems.
Eli
Yes, I figured that part out lol...the thing is I need to be able to constantly update the csv file. Its a program for the hose department at my engineering job. They need to be able to add data throughout the day...week..whatever and then if they need to view something, be able to pull up all data. So me converting and saving the file wont work
 
There is a feature in Excel to "Share workbook". That allows multiple users to open and edit the same excel file at the same time.

Even with this feature, I think that instead of Excel you are need to consider a system based on a database with concurrent users.
 
So there's no way for me to read the .csv file, convert it to .xls and then have it show up on datagrid?....bc if I just straight tell the program to read from the csv file, it says it cant be read. I cant have the employee go straight into the excel file. This has to be "dummy" proof they said.
 
It is totally unclear what you are trying to achieve.
It has something to do with VB, and Excel, and CSV, and some employees.
Try to describe the entire task in detail.
 
if I just straight tell the program to read from the csv file, it says it cant be read. . .So me converting and saving the file wont work
From past experiece, often the reason a file can't be read is that it is already OPEN (by some other program or command). If you can't convert CSV to XLS, then your only choice is to make and keep the file as an XLS Excel file to start with. Then you don't have to convert it (although conversion should be easy).

After each change, use your Visual Basic program to call Excel, load the CSV file, then save it as a XLS file, then CLOSE the XLS file. Now you always have an updated spreadsheet that can be opened and viewed by anyone else.
 
Last edited:
Ok, lemme try this.. (sorry, im bad at trying to tell someone what im doing over the internet.)

So where I work, there are the engineers inside and we have a shop in the back. My boss wants me to create a form in vb. The program needs to be created so the employee who creates hoses for jobs outside (pressure hoses) can input the job number, serial number of the hose, hose size, hose type, ect into the form and hit save.

once he hits save, the information he inserted will be saved as a csv in excel. (i got this code to work)

Now the issue is, lets say he makes an error, or needs to go back and double check something. I created a button (display hoses) which he will click. once clicked, I need all that information to pull up from the day he first entered his first hose information to the last one he did( current) into a datagrid so he can view all of the data.

The problem is, I can get the code to read from an .xls file and it'll display where I want it, but not my csv file. So I need to figure out how to convert my csv file to an xls file, then write my code to display it so he can view the data anytime he needs.
 
how do i do that Lancie?

Im so new to all of this, so my skills arent where they need to be. Im trying to learn how to do this the same time im writing this
 
Last edited:
how do i do that?
(1) Open the CSV file using the Microsoft Excel software program. (2) press "File, Save As", then select "Save as type:" select "Microsoft Excel Workbook (*.xls)" for Excel 97 to 2003.

For later versions of Excel, do a Save As file type *.xlsx

It helps to set Windows Explorer to show all file type extensions, so you know what type each file is saved as. Open windows Explorer, select "Tools, Folder Options, View", then unselect "Hide extensions for known file types".
 
Last edited:
CSV works good and simple for easily saving data for later opening by a viewer (such as Excel). But for more complicated functionality, CSV is not suitable.
Concurrently writing to and opening by another program is not possible. When reading back from the CSV file there is no error checking. You would have to make your own error checking code.

Converting to an Excel file isnt much better IMO.

What you describe, sounds to me that you definitely need to save to a database, and not an Excel or CSV file.
A database will take core of concurrently reading and writing, restricting users to read only, make sure that the data isnt messed up, can make a backup at runtime, etc.
 

Similar Topics

Due to a lack of upkeep and understanding of my predecessors, I have a PLS71 that was running V16 of Logix. I need to swap out an AENT for an...
Replies
2
Views
696
Hello, I am updating a project that uses FTView 8.1 SE Network station. During layoff due to Covid, I made the changes but it was with FTView 10...
Replies
8
Views
3,104
Hi all. I have a working program from a compactlogix platform that I have to convert to an existing SLC500. I am rewriting it manually at the...
Replies
4
Views
4,213
Hello All, I need the ability to remotely reboot a Red Lion CR3000 HMI. Due to some graphics issues when the database is updated the HMI must be...
Replies
4
Views
204
Hello The plant is running and there is no shutdown nowadays therefore I can add 1734- AENTR and its card while PLC is in Run? I do not wanna...
Replies
8
Views
332
Back
Top Bottom