×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How can I read Excel files from QBASIC?

How can I read Excel files from QBASIC?

How can I read Excel files from QBASIC?

(OP)
I need to read an Excel spreadsheet from my Qbasic program (the speadsheet is just lots of rows of normal data - numbers and text).  I have tried various 'save as' options from Excel (e.g. CSV (comma delimited)) to try and get it to a format that Qbasic understands but all I get is 'bad file name' when I try to open the file from Qbasic.

Any help much appreciated.

RE: How can I read Excel files from QBASIC?

Excel files are so complicated that I don't think you could decode them, you have to deal with things like spacing, formulas, formatting, it would be incredibly difficult.  It would be much easier to build your own spreadsheet program.

RE: How can I read Excel files from QBASIC?

Markh999:

1) If you 'SAVED AS' a CVS file, QB will absolutely be able to read it.

2) Only help I can give you (since you didn't post any code to review) is to save the CVS in the 8.3 format and don't use LFN...QB can't understand it since it wasn't designed with that in mind; this includes directories as well.

3) Post the code you wrote so we can all GUIDE you to a solution.

--MiggyD

RE: How can I read Excel files from QBASIC?

(OP)
Thanks to both of you for the response.  Here is some more info that may help (as I'm still getting problems).

I save my Excel spreadsheet as as 'CSV (comma delimited)' file and called it 'football results csv'.  It then saved the file as the name 'football results csv.csv'

In my QBASIC program I have the following code

OPEN "football results csv" FOR INPUT AS #1

and it says File not found.

I have tried OPEN "football results csv.csv" FOR INPUT #1 and it says Bad file name.

I've tried putting a path, so OPEN "c:\Qbasic\football results csv" as INPUT #1 and I get File not found again.

So its looks like its not even detecting the file, let alone trying to interpret the data !

I'm sure its something simple but its beaten me.  Any further help would be very gratefully received.  If I can post any more info please let me know.

Thanks again.

RE: How can I read Excel files from QBASIC?

As I said in paragraph #2 above: "...save the CVS in the 8.3 format and don't use LFN...".  But you are still using the Long File Nameing [LFN] format. Please re-read the above first then continue with the rest of this response.  You need to do ONE of the following TWO options:
NOTE: This is considering that the CVS file is saved/located in the same directory as your QB.


OPTION 1 -> use 8.3 in your QB code.  In other words, change the following in your code:

FROM:
        OPEN "football results csv.csv" FOR INPUT AS #1
{see the LFN format you are using?}

TO:
        OPEN "footba~1.csv" FOR INPUT AS #1
{see the "~1"?}
{The length of 'FOOTBA~1' = 8}
{The extension of 'CVS' = 3}
{see the 8.3 format in my revision?}



OPTION 2 -> "Save/Save As" the data in the 8.3 file nameing format already for easier access with your QB program.  In other words;

->(in Excel)<- do the following
>Click FILE
>Click SAVE AS
>Type FOOTBALL in 'file name' only [note: this word is 8 characters]
>Change 'Save Type' to CVS [note: this makes the .3 characters]
>Click SAVE button
{see how this adds up??}
{F O O T B A L L . C V S}
{^ ^ ^ ^ ^ ^ ^ ^   ^ ^ ^}
{| | | | | | | |   | | |}
{1 2 3 4 5 6 7 8 . 1 2 3} = 8.3


->(in QB)<- change the following:
FROM:
        OPEN "football results csv.csv" FOR INPUT AS #1
{see the LFN format you are using?}

TO:
        OPEN "football.csv" FOR INPUT AS #1
{see the 8.3 format in my revision?}



Hope this clarifies it for you.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close