Categories > OpenTBS with XLSX >

OpenTBS from Binary string?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SanderK
Date: 2013-05-30
Time: 16:41

OpenTBS from Binary string?

Hi everyone!

I need help, quite desperate by now... :(

How can I load an Open TBS template directly from a binary string?

I tried this (found in the manual):
$TBS->Source = $binary_stringed_file;
$TBS->LoadTemplate(null);

But then I get "TinyButStrong Error OpenTBS Plugin: The template '' cannot be found. The process is ending, unless you set NoErr property to true."

I really hope that someone can help me... Thanks a lot in advance!

SK
By: SanderK
Date: 2013-05-30
Time: 23:34

Re: OpenTBS from Binary string?

...did some extra research and found that the unzipping-part makes it very difficult to load a string.

Since my webserver cannot store local files except for tmp files, and then ONLY with tmpfile() and not with fopen() (it sucks, I know..), I could also use a solution in which the used handle becomes the tmp file()-handle somehow.

Would that be easier..?

SK
By: Skrol29
Date: 2013-05-31
Time: 02:12

Re: OpenTBS from Binary string?

Hi SanderK,

OpenTBS cannot support a binary string as template, despite TBS can do it.
OpenTBS would need an enhancement in order to support a handle instead of a named file.

But did you tried to create a temporary file using tempnam() instead of  tmpfile() ?
By: SanderK
Date: 2013-05-31
Time: 10:21

Re: OpenTBS from Binary string?

Hi Skrol,

Thanks for your responce.

Tempnam is blocked (because it uses a path). tmpfile really is the only option. But that also creates a handle! So it could be working right?

The question is where the path is used in the script.. I made the first step (loading the handle into the ArchHnd), but something goes wrong with loading the handle for the unzipping. Where does this happen in the script? I cant find it... :s
By: Skrol29
Date: 2013-06-01
Time: 00:02

Re: OpenTBS from Binary string?

Hi,

Here is a beta version that should support a PHP Stream Resource as template file.
If it's working properly for you it will be released as a new version.

http://www.tinybutstrong.com/dl.php?f=tbs_plugin_opentbs_beta.zip&s=2
By: SanderK
Date: 2013-06-02
Time: 17:11

Re: OpenTBS from Binary string?

Hi Skrol,

That sounds very very promising!

I tested the betaversion you gave me, and it almost worked. When I do
$TBS->LoadTemplate($handle);
My browser downloads the file (I use Show with OPENTBS_DOWNLOAD for testing), but when I try to open the file with Excel it says "Excel cannot open this file".

Any idea where that comes from?

PS: You got me quite excited! If this works, it would mean a lot to me...!
By: Skrol29
Date: 2013-06-03
Time: 01:53

Re: OpenTBS from Binary string?

Hi,

It works with my tests.
Can you check your script with the debug mode?
Or can you send to me a piece of code that reproduces the bug?
By: SanderK
Date: 2013-06-03
Time: 10:54

Re: OpenTBS from Binary string?

Hi Skrol,

I have sent you the package containing the code that reproduces the bug!

SK
By: Skrol29
Date: 2013-06-03
Time: 23:35

Re: OpenTBS from Binary string?

By: SanderK
Date: 2013-06-03
Time: 23:51

Re: OpenTBS from Binary string?

YEESSSSSS!!!! You are a genius!! :D

It works perfectly. Thank you very very much.

I really appreciate this plugin.

One tip: I really like it that it doesn't touch the macro's. Maybe you can promote the plugin a little more with that... (and if it will be possible to EDIT the macro's one day, you will be the very first I believe...)

One more time: thanks a LOT!
By: Skrol29
Date: 2013-06-04
Time: 14:26

Re: OpenTBS from Binary string?

Hi,

> One tip: I really like it that it doesn't touch the macro's

Unfortunately Macros are saved as a binary contents in the archive.
The source code is not easily readable.
By: SanderK
Date: 2013-06-04
Time: 14:44

Re: OpenTBS from Binary string?

I thought so. I am already very happy with the way it is now :)
By: SanderK
Date: 2013-06-06
Time: 12:53

Re: OpenTBS from Binary string?

Hi Skrol,

There is one more problem that occurred. It has nothing to do with the file handle, but I don't know where it comes from.

In the script I send you before, I unquoted the
$TBS->PlugIn(OPENTBS_SELECT_SHEET, "UITGAVEN");
row.

When I unquote it, the script gets stuck on that specific row for minutes. Then, finally, it breaks and gives:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /test.php.

Reason: Error reading from remote server

Any idea where it comes from? Or is there an alternative to the select_sheet?

Very strange that it worked before, but doesn't anymore... :(
By: SanderK
Date: 2013-06-07
Time: 15:52

Re: OpenTBS from Binary string?

FOUND IT! After hours of testing I found the problem:

When you freeze panes in your file, it cannot load!

Why is this? Is there something I can do about it?
By: Skrol29
Date: 2013-06-07
Time: 22:21

Re: OpenTBS from Binary string?

> freeze panes

What do you mean ?
By: SanderK
Date: 2013-06-10
Time: 10:04

Re: OpenTBS from Binary string?

I mean 'locked' rowes that stay in place even if you scroll your page. Do you know what I mean?

Its used a lot for displaying the upper row of a long table, so that you kan always see the names of the column, no matter how far down you scroll.
By: SanderK
Date: 2013-06-10
Time: 18:39

Re: OpenTBS from Binary string?

I'm sorry, I was wrong. Something else is wrong with the excel sheet, it has nothing to do with the frozen panes :(

I don't understand... The sheet 'DEKKINGSPLAN' can be loaded, but the sheets 'UITGAVEN' and 'BEGROTING' can not. In has worked but not anymore.

How many rows can OpenTBS handle?
By: SanderK
Date: 2013-06-10
Time: 20:03

Re: OpenTBS from Binary string?

Alright, after another evening of testing lots of things I found out something else: the sheet I want to load (UITGAVEN) contains 1500 rows. When I delete 1490 of them (leaving 10 rows), the script works again. So it looks it has something to do with the number of rows.

The strange thing is that it worked before with 1500 rows. And of course I need 1500 rows... :(

(one more small idea: is it possible to load only one column from a sheet instead of the entire sheet?)

I've got my entire script working by now, except for this small but so frustrating hick-up. So I don't dare to be too exciting about it just yet...
By: Skrol29
Date: 2013-06-10
Time: 23:34

Re: OpenTBS from Binary string?

> (one more small idea: is it possible to load only one column from a sheet instead of the entire sheet?)

Of course not.

If you could sent to me a snippet that reproduces the bug, I could study it.
By: SanderK
Date: 2013-06-11
Time: 11:52

Re: OpenTBS from Binary string?

Email sent :)

Thanks a lot for your time, means a lot!