Very newby at this.
I need to open an existing excel xml file, change a few lines and print it.
Any examples here on simple MS Excel routines?
Hi Peter,
If your application is such that it will be just as acceptable, then maybe you can simply recreate an entire new workbook rather than open an existing one, change lines, and print. I am working on a class in another thread that creates the xml workbook files.
If you need to open an existing workbook then COM automation is your best choice. Do a search on PowerBASIC's forum for something like "reading excel". You will get lots of hits.
http://www.powerbasic.com/support/pbforums/showthread.php?t=43734
http://www.powerbasic.com/support/pbforums/showthread.php?t=42548
You might be able to simply use text search and replace methods. It depends on how drastic are your changes.
Load a copy of your xml file into a text editor and give it a try. You could find "Robert" and change it to "William"
and it probaby would work fine. But major changes would be best done by rewriting the file as Paul suggested.
If you have a copy of SQLtools you can possibly open the Excel workbook with ODBC and handle changes just like it was a small SQL database.
I have done limited changed this way before but I don't have any current example without some digging around.
Of course SQLtools is not free.
Thanks a million. Will give it a try!
Hi All
I have come to a bit of a standstill on this matter. I am doing something wrong here.
The links on this page at Powerbasic leads back to the Powerbasic examples in the PB folder.
Those examples work fine if you EXCLUDE Firefly. The moment I try to ADD that EXCEL.inc to Firefly I run into many problems.
What must I include in my FF project and does the calls differ from the example in PB? Because they wont work if I run them from my FF project.
It would be quite a bummer if I cannot get it to work as this is an integral part of the program.
Excel has many objects, e.g. Rectangle, that conflicts with API functions of the same name. Generate a new include file adding a prefix, e.g. "Excel_".
Thanks Jose, but I fear I am too much of a newby to know where I must alter what, I am going to mess up that Include file.
What i need is a bit more elementary examples in Firefly on how to create a new Excel sheet and send data from my Listview over to Columns in Excel.
I am CLUELESS. :(
I don't have Excel, so I can't help you with that. Sorry.
Rather than use COM, maybe you can try my new SLL that creates Excel compatible files. It is incredibly easy to use and wrap your head around. There is a sample included in the package that shows how to create a file, output rows and columns, format cells, etc...
Check it out: http://www.planetsquires.com/protect/forum/index.php?topic=3208.0
Thanks a million Paul!
In just a few minutes i was already creating the XML files!!!
Now just to get the system to open them automatically!!!
This was an easy way around!!!! :)
see the last posts of this thread...
http://www.powerbasic.com/support/pbforums/showthread.php?t=45652 (http://www.powerbasic.com/support/pbforums/showthread.php?t=45652)
basically...
Local xptr As Long
Local b As String
b= "D:\my_excel.xml"
xptr=StrPtr(b)
ShellExecute 0, "open", ByVal xptr, $Nul , $Nul, %SW_SHOWMAXIMIZED
Works well and fast. I use it mostly for pdf's.
Thanks all.
I have made a function that will export any Listview to Excel, including column sizes and all data in one quick click.
Thanks to all of your help.
I had a very strange problem and thought it might help somebody else.
I have a computer at work with a separate license for FF and PB10. I build a project with these Excel routines and the .SLL and everything worked fine. I was using FF 3.61 and PB 10.03.
I started a new project on my home machine with FF 3.61 and PB 10.00 (never been patched). When I compiled FF would hang with the "program has stopped" message. Not PB but FF. I tried to compile the sample project with PB 10.00 and got a strange error but no crash.
I updated to PB 10.04 and everything now works. I am not sure how the PB compiler could crash FF but it did.
BTW --- These Excel routines are AWESOME!!!!!!