Read/Write Excel Files

Blitz3D Forums/Blitz3D Programming/Read/Write Excel Files

Tony Hart(Posted 2005) [#1]
I have searched through the code archives and everything to try to find a program source code that would help me learn how to read and write excel files but my search has come up with nothing.

What I am trying to do is this. Say I have 25 rows of data in one excel file with 10 columns of data. I would need to take each row individually, read the data, and have it take the data and put it in a new excel file that is formatted like a form. I need it to take column 1 and put it in the Name box in the excel form template I created, column 2 would be the address and it would put it in the address section on the form, etc.

I have the base files I need to use, I just need to learn how to read and write excel files and how to tell it where to put the information.

I am trying to write this program for my friend who works at an escrow office. He passes tons of these files a day and a program like this will increase his efficiency at least 10 fold. As of now, what my friend has to do is look at the file he gets from his lenders which contains the rows of data, then individually goes and types each column of data from the row into the form template he uses. As you can plainly see this can be very time consuming and hence he has to make his lenders wait longer.

If you could point me in the right direction, or possibly send me a sample source that would read a random number of rows I would be most appreciative. Let me explain on that. Like i said earlier, say the file has 10 columns on every row of records, but file one has 10 rows, file 2 has 38 records, and file 3 has 22 records. What I want it to do is take each file, read how many rows of data it has, and makes the same number of form files. So in the first file, it would make 10 forms using the 10 columns of data. File 2 would make 38 forms using the 10 columns of data, and file 3 would make 22 form files using the 10 columns of data.

I would be able to take a program like this and edit it to however many columns of data the rows have so I could use it for other purposes as well.

I don't need it to batch read multiple files. I just need it to read one file and create the multiple files properly according to the data written inside of the source file

If i could get something like that it would be most appreciative.

I purchased Blitz3D and have written some of the learning games but I havent gotten that good yet and I havent been able to find anything that would help me get this program written.

Thanks for your time!


Mystik(Posted 2005) [#2]
Wouldn't it be much easier to use the built in Visual Basic to do this?

I should imagine it would be quite tricky in Blitz unless you saved the sheets as text first.

Here are some links that may help:-

http://www.wotsit.org/download.asp?f=xls
http://www.wotsit.org/download.asp?f=excel

Steve.

Steve.


Stevie G(Posted 2005) [#3]
If you convert the xl files to .csv it shouldn't be too difficult to parse the data and manipulate it using an external program.


Banshee(Posted 2005) [#4]
I did a lot of Blitz based Excel manipulation at work a while ago, but rather than spend a few months working on an importer/exporter I just converted the files to tab-delimited whilst I passed them through my programs.

Be warned, doing half my job with Blitz programs got me reduced to a two day week because I had no other work left to do. The company where mighty impressed at the saving I had made for them... I left shortly afterwards and my Blitz demo compiled programs hopefully stopped working shortly after that.


Bot Builder(Posted 2005) [#5]
MS office file formats are horrid. You have almost 0 hope of importing them. I suppose you might be able to create a dll that imports them... maybe. I just opened up the excel files in openoffice, saved and read the result of that which wa relativly easy.


John Blackledge(Posted 2005) [#6]
A csv file isn't hard to create in Blitz.

Save a spreadsheet from Excel in csv format, open it in Notepad, look at the structure.
You obviously have to know the general structure of what you are creating, rows, columns etc.

I've created csv files in Blitz, and Excel reads them just fine.


Sweenie(Posted 2005) [#7]
Does the form have to be made in Excel?
If not, I would suggest creating the form in Word and use the "reference document guide"(Direct translation from swedish) to read the data from the source Excelfile.
I'm not quite sure what it's called in the English version, might be Mail Merge.
You'll find it under the Tools menu.
That would save you alot of time.

Anyway, I suggest sticking to Excel and VBA as long as it's possible because involving an external application is often not worth it.

If you want to involve another language anyway, I would suggest Visual Basic 6 or VB.NET/C#.
That way you can make use of the CreateObject function and make an instance of the "Excel.Application" COM object to interact with Excel.