Save data from PB to OO Calc format files (multiplatform) ?

Everything else that doesn't fall into one of the other PB categories.
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Save data from PB to OO Calc format files (multiplatform) ?

Post by agb2008 »

I am looking for solution that could be implemented in PB to save data in OpenOffice Calc format or
OpenDocument / OpenXML formats that could be used with OpenOffice/MS Office... I am aware of few existing
tools, such as ExcelWriter but I am trying to find multiplatform solution that would work on all platfroms including
Linux and MacOS and as well be compatible with 32 and 64 bit applications (in case of external library).

Resulting document is quite simple spreadsheet table with very basic formating - no formulas or other advanced
staff.

Also, I am looking for the simple report generator type solution - but once again that could be used in multiplatform
applications - i.e. would work on Windows,Linux and MacOS 32/64 bit.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Save data from PB to OO Calc format files (multiplatform

Post by collectordave »

Can I try to deal with the simple report generator first.

I have written a simple one available here:-http://www.purebasic.fr/english/viewtop ... +Module%3A

Hope that helps there.

I am also looking to send data to OO documents as well. Started to look at it all and .ODT and .ODS files are zipped archives of several files. Started with the premise of not attempting to create the files from scratch but to use empty files created by OO. Also not looking to write a UNO bridge as I want it all to be cross platform. All routines need to be in PB native code.

So first job of unzipping ready for modyfication I have done. If you look here http://www.purebasic.fr/english/viewtop ... &hilit=zip.

Next step is getting the xml manipulation code together to update the files. I am just making a start on this. May take some time so any help would be appreciated.
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: Save data from PB to OO Calc format files (multiplatform

Post by agb2008 »

collectordave:

Thank you for reply. I would try to test one that you mentioned in your post. Am I understood you correctly - it's suppose to
work on all platforms - not only Windows one ? I also tried to check existing solutions - but they either commercial ones with very high
cost (which I can't afford for my private project) or available only for specific platorm (mostly Windows) and got limitation in terms of
suporting only 32 bit applications... There are few solutions written in Java - but, at least for my case, I can't mix native code and Java.

Interesting projects that I found (unfortunately I can't use them - because of limitations mentioned above) - but ones that might be of
some use for others (all of them available in a form of shared library i.e. DLL for Windows and some for other platforms):

1. Oxetta reprorting engine, light-weight, fast and powerful printing library: http://www.oxetta.com/
2. Lime Report, report generator engine for QT framework: http://limereport.ru/en/index.php
3. XPort/XPortPro: http://xportpro.com/index.php

Of cause that's not all available options - but the ones, that were not mentioned on the forum.

As for my project - right now I am trying to use PurePDF library capabilities. If I understood correctly it's available for all platforms
and could be used for both 32 and 64 bit applications. So far I've done some tests on Windows OS. Basic capabilities such as document
with header, footer, table and text could be implemented right away. In my case I also need some graph type objects - no such options
exist out of box - but I think it should be possible to create ones by using basic drawing primitives available in PurePDF.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Save data from PB to OO Calc format files (multiplatform

Post by collectordave »

Hi

The report creator i mentioned above will be cross platform and allows graphics (images) in the header section. I am trying to make my projects cross platform I am collecting a lot of little things which aren't together into a module to give the cross platform capability. The report creator is only in it's initial stages as yet but i am looking to enhance/debug it. If you have any suggestions or problems please post on that thread. I use it allready to produce simple reports from a small database I have.

You also mention the PDF library. I have allready coded a cross platform print module that uses the vector drawing commands some examples of usage are on the forum. I am interested in the OO parts to add to this module along with PDF capability again cross platform so printing will be a simple choice for the programmer. Choose either preview, print directly, PDF or OO. Just a dream at the moment but moving towards that.

As I mentioned in my first post I want the OO routines to be in native PB which gives the best chance of all being cross platform.

If I can help further just send a PM.

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.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Save data from PB to OO Calc format files (multiplatform

Post by collectordave »

Just a quick update.

I have now successfully created an OpenOffice calc document with some data in cells etc where I want it.

Very early days yet but could you post some typical data that you would like to insert in a calc sheet? I can use that to test.

If in array form it will need Row,Column,Data and type. the type will have to be float for numeric data and string for text but all the data will need to be text.

Something like

Code: Select all

Structure
  Row.i
  Col.i
  data.s
  Type.s
Endstructure
The type.s could be Type.i and provide some constants to assign values such as

Code: Select all

#Text = 1
#Integer = 2
#Float = 4
etc.

regards

cd

__________________________________________________
Code tags added
04.04.2016
RSBasic
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
blueb
Addict
Addict
Posts: 1121
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Save data from PB to OO Calc format files (multiplatform

Post by blueb »

agb2008 wrote:...

1. Oxetta reprorting engine, light-weight, fast and powerful printing library: http://www.oxetta.com/
2. Lime Report, report generator engine for QT framework: http://limereport.ru/en/index.php
3. XPort/XPortPro: http://xportpro.com/index.php
Thanks agb2008,

I hadn't heard of Oxetta, but I downloaded it and besides a Report Designer, it can also be used with oxetta.dll

Looks like only 4 functions:

ASCII:
oxiPreviewA
oxiPrintA
UNICODE:
oxiPreviewW
oxiPrintW

Now I need to figure out a way to make it work :mrgreen:
- 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
Bo Marchais
User
User
Posts: 61
Joined: Sun Apr 03, 2016 12:03 am

Re: Save data from PB to OO Calc format files (multiplatform

Post by Bo Marchais »

I take it simple .csv exports won't do it? You can even call them .xls if you like, and most office packages can be set to auto-import them.
The hardest part is just escaping text correctly. Lots written about that on the web.

I've made a lot of people happy just reading and dumping out .csv data - almost any spreadsheet will read it, and it isn't that hard to escape special characters if you need text. It won't help with formatting, of course, or if you need formulas. I've also written out reports as html that can be opened with - and printed - from browsers locally. There are limits, of course, but modern browsers are very, very good at rendering css (and you can define .css stylesheets for a printer device) and thus any browser can render reports for printing. There are minor issues with pagination when using browsers.

Many simple reporting engines are little more than this, anyway.

Universally, .pdfs are an excellent way to get reports out. I have had good luck also with writing out .svg files and turning them into .pdf files or opening them in firefox/webkit browsers, as well as exporting html into .pdfs. I believe there are pdf creation libraries for purebasic, and if worse comes to worse, you can create raw pdfs by hand. A good xml library can help you create raw odt files, and you can control open office from it's API as well. I've also generated postscript, and had it converted to .pdf by shelling out to utilities called by the main program.

For the .docx and .odt solutions, just open them up in a .zip utility and look at the contents using notepad++ - I don't know how good the zip utilities in purebasic are yet, but you could create a few sample templates in OO/LO and then replace the parts you want to change using nothing more than text processing. It's not too hard to understand. There's a world of difference between writing a universal reporting tool and just knocking out some good looking reports - the latter is much easier.

If your target is linux, you have a MILLION options - there are so many utilities for this kind of thing!
If your target is windows, you may have to have your clients install open source software, but you can get the same things.
The commercial stuff isn't bad, either, but it's expensive and licensing the .dlls is a drag.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Save data from PB to OO Calc format files (multiplatform

Post by collectordave »

Hi again

Just posted code module to write Open Office spreadsheets here http://www.purebasic.fr/english/viewtop ... 12&t=65415

Starting to look at Open Office text documents now.

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.
Post Reply