|
1 # Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of the License "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 # |
|
16 # Description: |
|
17 # TableFormatter/Csv.pm |
|
18 # |
|
19 |
|
20 package TableFormatter::Csv; |
|
21 |
|
22 use strict; |
|
23 use Utils; |
|
24 use TableFormatter; |
|
25 use vars qw/@ISA/; |
|
26 @ISA = qw(TableFormatter); |
|
27 |
|
28 sub PrintTable { |
|
29 my $self = shift; |
|
30 my $data = shift; |
|
31 my $location = Utils::PrependEpocRoot("\\epoc32\\relinfo\\temp-table.csv"); |
|
32 open(CSV, ">$location") or die "Couldn't open \"$location\" for writing because $!"; |
|
33 foreach my $row (@$data) { |
|
34 my $rowtext = ""; |
|
35 foreach my $cell (@$row) { |
|
36 $cell =~ s/\"/\\\"/g; |
|
37 $cell =~ s/(.*)/\"$1\"/ if $cell =~ m/[\,\"]/; |
|
38 $rowtext .= $cell . ","; |
|
39 } |
|
40 chop $rowtext; |
|
41 print CSV "$rowtext\n"; |
|
42 } |
|
43 close CSV; |
|
44 system ($location); |
|
45 } |
|
46 |
|
47 1; |
|
48 |
|
49 __END__ |
|
50 |
|
51 =head1 NAME |
|
52 |
|
53 TableFormatter/Csv.pm - Formats tables in text |
|
54 |
|
55 =head1 INTERFACE |
|
56 |
|
57 =head2 New |
|
58 |
|
59 Creates a formatter. |
|
60 |
|
61 =head2 PrintTable |
|
62 |
|
63 Prints the table. Two arguments: firstly, a 2D array of the data. Secondly, a Boolean specifying whether the first row is a header row. |
|
64 |
|
65 =head1 KNOWN BUGS |
|
66 |
|
67 The name of this file (i.e. Csv.pm) must be in that capitalisation, for IniData.pm to be able to find it. |
|
68 |
|
69 No actual bugs. |
|
70 |
|
71 =head1 COPYRIGHT |
|
72 |
|
73 Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
74 All rights reserved. |
|
75 This component and the accompanying materials are made available |
|
76 under the terms of the License "Eclipse Public License v1.0" |
|
77 which accompanies this distribution, and is available |
|
78 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
79 |
|
80 Initial Contributors: |
|
81 Nokia Corporation - initial contribution. |
|
82 |
|
83 Contributors: |
|
84 |
|
85 Description: |
|
86 |
|
87 |
|
88 =cut |