User Module:Open Office Write spreadsheet

Share your advanced PureBasic knowledge/code with the community.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

User Module:Open Office Write spreadsheet

Post by collectordave »

Just a user module to allow the creation and writing of Open Office spreadsheets.

Thanks to all on the forum that helped.

Use the dropbox link below to down a zip with the project files.

Unzip the project and run. (No exe in download so you need PB. Load the project and run. Click the button and you will be promted for a filename. Enter the filename and it will be created with some test data in the folder. Double click the file to run Open Office and you will see the spreadsheet.

Code fairly self explanatory but if more info required leave post here.

The module will be changing as i wish to add procedures to extract data from the spreadsheet and maybe add style etc.

If anyone has any suggestions or can help enhance the module please leave code snippets here and I will incorporate them as and when I can.

Edit 08 April 2016

Seems to be some problems. Changed all "\" as path seperators to "/". Added a little checking to ensure files exist.

Code removed.

Tested with PB5.42LTS on Windows 7 and PB5.41LTS on MAC OS el kapitan

Dropbox link for project files added:- https://www.dropbox.com/s/2jfh2o3kudu3d ... e.zip?dl=0

Regards

CD


Enjoy
Last edited by collectordave on Thu Dec 01, 2016 4:25 pm, edited 3 times in total.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
infratec
Always Here
Always Here
Posts: 7588
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: User Module:Open Office Write spreadsheet

Post by infratec »

Hi,

just for information:
it works also with LibreOffice 5.1

Bernd
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: User Module:Open Office Write spreadsheet

Post by yrreti »

I appoligize, but I've got a busy schedule today and have to go.
But I tried with LibreOffice which I always use, and it always crashes here in the WriteCalc.pbi file:
I ran the code as directed in the notes.
(It's probably something simple and stupid, but I just don't have time to look at it further right now.)
*I do appreciate your sharing this code though.*

WriteCalc.pbi:

Code: Select all

  Procedure DeleteRows()
   
    ;Procedure to delete current cell detail from document
        
    *CurrentNode = XMLNodeFromPath(RootXMLNode(loadedxml), SpreadSheetPath);****  CRASHES HERE   <------<<<<
    For child = XMLChildCount(*CurrentNode) To 1 Step - 1
      *child = ChildXMLNode(*CurrentNode, child) ;****  or CRASHES HERE everytime   <------<<<<
      ;                                                                    [Error] The specified #XML is Not initialized
      DeleteXMLNode(*child)
    Next
    FormatXML(loadedxml,#PB_XML_ReFormat )

 EndProcedure
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: User Module:Open Office Write spreadsheet

Post by collectordave »

hi yrreti

Can you let me know which OS you are using/

The only thing I can see with the error you are getting is where the xml is loaded. The content.xml file should exist after the crash in the \Temp folder in whichever folder you are running the programme from. The temp folder is deleted after a successfull operation.

Code: Select all

      ;Load the xml from the content.xml file
      loadedxml = LoadXML(#PB_Any, GetCurrentDirectory() + "Temp\content.xml") 
I do no error checking there at all so first check that the file exists on the path specified. If you are running a MAC maybe the backslash should be a forward slash. If the file exists you could add the lines

Code: Select all

    If XMLStatus(loadedxml ) <> #PB_XML_Success
      Message$ = "Error in the XML file:" + Chr(13)
      Message$ + "Message: " + XMLError(#XML) + Chr(13)
      Message$ + "Line: " + Str(XMLErrorLine(#XML)) + "   Character: " + Str(XMLErrorPosition(loadedxml))
      MessageRequester("Error", Message$)
    EndIf
and see what you message you get.

Please let me know how you get on.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: User Module:Open Office Write spreadsheet

Post by agb2008 »

collectordave:

I've tried you code on Windows 64 bit with PB 5.41 LTS (64 bit) and got results similar to
ones reported by yrreti : crashing with error in WriteCalc.pbi (Line: 162)

[ERROR] The specified #XML is not initialised.

P.S. The error above happening because application tries to read data from Temp\content.xml file
and that file does not exist...
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: User Module:Open Office Write spreadsheet

Post by collectordave »

Problems with missing files it seems.

Now updated original post with a dropbox link to the project files as zip. No exe file just text and a Template.ods file.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: User Module:Open Office Write spreadsheet

Post by yrreti »

Hi collectordave

Is it possible to get an update of this program again?
Your dropbox link has been removed.
I really have a need to try experimenting with it again.
Doing it manually is a pain in the butt.
Thanks for your help.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: User Module:Open Office Write spreadsheet

Post by collectordave »

Hi

Just back after a little problem. Working through the programmes I was doing at the time. When I get to it I will post again.

sorry for any problems.

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: User Module:Open Office Write spreadsheet

Post by collectordave »

Hi

Tested code quickly and still seems to work so link in first post updated and enabled again.

Regards

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: User Module:Open Office Write spreadsheet

Post by Lunasole »

@collectordave thanks, that was a pain to search reliable and independent (without MS Office required, etc) way of working with sheets from PB (I found only one independed library looking nice, and it is proprietary). At least your code might allow writing of those sheets, will try it somehow ^^
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: User Module:Open Office Write spreadsheet

Post by collectordave »

@Lunasole

I will be moving onto that later to develop it further as I want to use OO, not MSword as wel, so if I can help drop me a line.

Regards

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
jdooley
New User
New User
Posts: 3
Joined: Sun Jun 05, 2011 8:05 pm
Location: Switzerland
Contact:

Re: User Module:Open Office Write spreadsheet

Post by jdooley »

Sorry to dig up an old thread, but does anyone have a copy of the file WriteCalcFile.zip?

Not surprisingly, the old dropbox link is dead.

Thanks.
"There is no passion to be found playing small - in settling for a life that is less than the one you are capable of living." - Nelson Mandela
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: User Module:Open Office Write spreadsheet

Post by blueb »

here is is: https://www.dropbox.com/s/lc5z3hzp0l9te ... e.zip?dl=0

It'll be here for a few weeks. :)
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: User Module:Open Office Write spreadsheet

Post by collectordave »

Project expanded you can now read and write OO spreadsheets.

No commate no api just straight PB here on this thread and as such should be cross platform.

viewtopic.php?f=13&t=76189
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply