Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something like "block=tbs:sheet" possible? #14

Open
nioate opened this issue Jun 5, 2021 · 3 comments
Open

Something like "block=tbs:sheet" possible? #14

nioate opened this issue Jun 5, 2021 · 3 comments

Comments

@nioate
Copy link

nioate commented Jun 5, 2021

I am not sure if this is the right place to ask, but I could not find another possibility:

I would like to repeat sheets in an ODS file instead of repeating rows in a sheet or cells in a row.
However it seems block=tbs:sheet does not exist.
And even if something like that is possible, LibreOffice does not allow sheet names including [ ] brackets.

Any way to solve this?

@roxblnfk
Copy link
Contributor

roxblnfk commented Jun 5, 2021

Have you tried using tbs:page?

@nioate
Copy link
Author

nioate commented Jun 5, 2021

No, I didn't know that.
I suppose I would need then "[tab.name; block=tbs:page]" as table name. However, this is not possible, because LibreOffice does not accept brackets in the table name.

@Skrol29
Copy link
Owner

Skrol29 commented Jun 6, 2021

The good place for help and support is https://stackoverflow.com/ using the tag TinyButStrong and OpenTbs.

It is possible to repeat sheets in an ODS file because they are all defined in the same sub-file which is the main file.

Example :

In the ODS template:
Choose a sheet in your template, name the sheet « MySheetName » (sheet names cannot have brackets like [ and ]) and put the following fields in a cell : [b;block=table:table], or [b;block=tbs:table].

At the PHP side:

// Include classes
include_once('tbs_class.php'); // Load the TinyButStrong template engine
include_once('tbs_plugin_opentbs.php'); // Load the OpenTBS plugin

// Initialize the TBS instance
$TBS = new clsTinyButStrong; // new instance of TBS
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin

//load template
$template = 'test.ods';
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8);

// sheets to repeat
$data = array(
	array('title' => "my sheet 1"),
	array('title' => "my sheet 2"),
	array('title' => "my sheet 3"),
);
// rename the tbs fields for the sheet name
$TBS->Source = str_replace('{MySheetName}', '[b.title]', $TBS->Source);
// merge sheets
$TBS->MergeBlock('b', $data);

// Finalize the merging
$output_file_name = 'resultat.ods';
$TBS->Show(OPENTBS_FILE, $output_file_name); // Also merges all [onshow] automatic fields.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants