Page 1 of 1

User Module:Open Office Write spreadsheet

Posted: Wed Apr 06, 2016 11:57 am
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

Re: User Module:Open Office Write spreadsheet

Posted: Wed Apr 06, 2016 1:22 pm
by infratec
Hi,

just for information:
it works also with LibreOffice 5.1

Bernd

Re: User Module:Open Office Write spreadsheet

Posted: Wed Apr 06, 2016 4:17 pm
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

Re: User Module:Open Office Write spreadsheet

Posted: Wed Apr 06, 2016 9:11 pm
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.

Re: User Module:Open Office Write spreadsheet

Posted: Thu Apr 07, 2016 2:59 pm
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...

Re: User Module:Open Office Write spreadsheet

Posted: Fri Apr 08, 2016 4:42 am
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.

Re: User Module:Open Office Write spreadsheet

Posted: Mon Nov 28, 2016 3:01 pm
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.

Re: User Module:Open Office Write spreadsheet

Posted: Thu Dec 01, 2016 2:03 pm
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

Re: User Module:Open Office Write spreadsheet

Posted: Thu Dec 01, 2016 4:27 pm
by collectordave
Hi

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

Regards

cd

Re: User Module:Open Office Write spreadsheet

Posted: Fri Dec 02, 2016 3:02 am
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 ^^

Re: User Module:Open Office Write spreadsheet

Posted: Fri Dec 02, 2016 5:49 am
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

Re: User Module:Open Office Write spreadsheet

Posted: Thu Jul 09, 2020 10:07 am
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.

Re: User Module:Open Office Write spreadsheet

Posted: Thu Jul 09, 2020 1:38 pm
by blueb
here is is: https://www.dropbox.com/s/lc5z3hzp0l9te ... e.zip?dl=0

It'll be here for a few weeks. :)

Re: User Module:Open Office Write spreadsheet

Posted: Sun Nov 01, 2020 2:57 am
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