BBC BASIC for Windows
General >> General Board >> excel spreadsheet
http://bb4w.conforums.com/index.cgi?board=general&action=display&num=1304851394

excel spreadsheet
Post by craven on May 8th, 2011, 10:43am

i use bb4w to run a basic pbm game, all my data is saved/loaded using the A=openin a$ and A=openout a$ commands and this is perfect for my needs but can anyone tell me if there is a simple way of getting microsoft excell to read these data files as well?

below is the open in format i am using at present

31600 A=OPENIN A$
31610 FOR J=1TO 40
31620 INPUT#A,ANAME$(J)
31630 INPUT#A,AAGE$(J)
31640 INPUT#A,APOS$(J)
31650 INPUT#A,AINJ$(J)
31660 INPUT#A,ALEVEL(J)
31670 INPUT#A,AMAX(J)
31680 INPUT#A,AQUAL(J)
31690 INPUT#A,ADP(J)
31700 INPUT#A,APLD(J)
31710 INPUT#A,AGOAL(J)
31720 INPUT#A,AGOALP(J)
31730 INPUT#A,MANAGER$(2)
31740 INPUT#A,RECA$(2)
31750 INPUT#A,RECG$(2)
31760 INPUT#A,GOALR$(2)
31770 INPUT#A,RECDPPLAYER$(2)
31780 INPUT#A,CASH(2)
31790 INPUT#A,DPTOT(2)
31800 INPUT#A,GPPTOT(2)
31810 INPUT#A,VPTOT(2)
31820 INPUT#A,FANS(2)
31830 INPUT#A,RECA(2)
31840 INPUT#A,RECG(2)
31850 INPUT#A,GOALR(2)
31860 INPUT#A,RECDPTOT(2)
31870 INPUT#A,RECDPPLAYER(2)
31880 INPUT#A,RECCASH(2)
31890 INPUT#A,RECTL(2)
31900 INPUT#A,CURTL(2)
31910 NEXT J
31920 CLOSE#A

any help would be most welcom
Re: excel spreadsheet
Post by admin on May 8th, 2011, 5:37pm

on May 8th, 2011, 10:43am, craven wrote:
can anyone tell me if there is a simple way of getting microsoft excell to read these data files as well?

Excel can read CSV (Comma Separated Value) files, so if you output your data file in that format Excel will be able to open it.

You can create a CSV file either by writing the code yourself, which is easy enough, or by using the code in this Wiki article:

http://bb4w.wikispaces.com/Reading+and+writing+CSV+files

Richard.
Re: excel spreadsheet
Post by craven on May 10th, 2011, 8:58pm

thanks richard but i do not understand it being the simpleton that i am!! i need to understand it before i can write it and i do not understand it!!
Re: excel spreadsheet
Post by admin on May 10th, 2011, 9:44pm

on May 10th, 2011, 8:58pm, craven wrote:
i need to understand it before i can write it and i do not understand it!!

If you prefer not to write your own code you can just copy-and-paste the PROCwriteCSV procedure from the Wiki; you do not need to understand it! The only disadvantage of simply taking the code from the Wiki is that it assumes your data will be in the form of a 2-dimensional string array:

Code:
      DIM array$(rows%,columns%) 

so if your data isn't already in a suitable form you will need to convert it.

The advantage of writing your own code would be that you get to decide the format in which the data is held. If you need more information on the Comma Separated Value file format this Wikipedia article has details:

http://en.wikipedia.org/wiki/Comma-separated_values

Richard.