Update: Just read the whole post.. And I had this problem as well. ( See bottom: )
TABLE TO EXCEL
I had this problem a few months ago and the following worked fine for me. The only real differences from the previous suggestions is I used the 'Range' property not the 'Range' method.
# This was inside a wrapper hence the Excel object was stored as b
+elow
my $book = $self->{Excel}->Workbooks->Add;
# I also had previously stored all the tables in the object
my $table = $self->{Tables}->[$i];
# Copy the table range
$table->{Range}->Copy();
# Add a new worksheet
my $sheet = $Book->Worksheets->Add;
$sheet->Paste;
$self->{Excel}->{DisplayAlerts} = False;
$sheet->Delete();
# Close the excel book
$book->Close( { SaveChanges => False } );
# Empty clip board
Win32::Clipboard->Empty();
Without meaning to sound a pesamist this will probably be the first of many prolems. I've been working on this for last few months and other issues you'll probably face will be:
- Merged cells: 'Only an issue if you actually want to extract the dat
+a when saved as txt tables (which I was)'
- Wraped cells in word: Wrapped cells will copy to excel to the number
+ of rows their text covers.
E.g.:
|----------------|
| A Heading |
| that is wraped |
|----------------|
becomes
|----------------|
| A Heading |
|----------------|
| that is wraped |
|----------------|
in excel
I've solved both the above and a few others but the solutions arn't really worth going to here.
- John
Update: I think you can actually used both
{Range} and
Range to represent the property but the code I listed definately works for me. (Sorry it isn't self containing but it's quite hard to put word table object in __DATA__ ;) (I'll probably be proved wrong though) )
TABLE TITLE:
The way I did this was to have a regular expresison mathcing the title paragraph and store the start location of each title and table and then merging the two arrays based on location ( My titles weren't always neatly above the table occassionally missing ).
For table start
$table->{Range}{Start}
For Paragraph start
$paragraph->{Range}{Start}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.