Thread Textformatierung (5 answers)
Opened by Kuerbis at 2014-06-24 15:24

GwenDragon
 2014-06-24 16:10
#176114 #176114
User since
2005-01-17
14533 Artikel
Admin1
[Homepage]
user image
Das geht bei Perl mit Reports (igitt ioch mag die nicht, weil nie richtig die Formatierung verstanden).

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl

use strict; 
use warnings;

my ($text, $value);

#23456789|123456789|123456789|123456789|123456789|123456789|123456789|123456789|
format = 
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>
dotize(65, $text), $value
.


sub dotize {
    my ($maxwidth, $string) = @_;
        return $string . " " . ('.' x ($maxwidth-length($string)));
}


foreach (<DATA>) {
    chop();
    ($text, $value) = (m/^(\D+)\s(\d.+)/);
    $text = "" if !defined $text;
    $value  = 0 if !defined $value;
    write();
}

__DATA__
Text text text text text 34.45
Text text text text 234
Text text text 345-347,532
Text text text text text text 445


Ergibt:
Text text text text text ........................................ 34.45
Text text text text ............................................. 234
Text text text .................................................. 345-347,532
Text text text text text text ................................... 44





Weitere Beispiele zu Reports mit Perl siehe auch http://affy.blogspot.de/p5be/ch11.htm#Example:%20U...


Aber du willst es wohl mit Libreoffice? Da gehts dann wohl nur mit einem LO-Makro.

Editiert von GwenDragon: Angepasst auf Daten des Beispiels
Last edited: 2014-06-24 16:18:27 +0200 (CEST)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Textformatierung