Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Good afternoon. I have a CVS file I want to open up within Excel, sort the file (anywhere from 1000 - 6000 lines of data) based on Column 'F' and then delete all rows with specific data in Column 'F'. I am only to the point where I can open the file and that is it. The file will not sort for me. My code is short and simple, and does not work how I want it to work. Suggestions would be greatly appreciated. I will end up adding much more to this file after sorting, but I need to get past this point first. Here is my code;

#!perl use strict; use warnings; use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; use File::Copy; $Win32::OLE::Warn = 3; # Die on Errors. #Open the needed file from server location my $excelfile = '\\\\ServerName\\FolderName\\FolderName\\FolderName\\F +ileName.csv'; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); #Open the file needed and activate the worksheet for manipulation ~ Tr +y to get a input box for entry of Branch name to open correct file... my $Book = $Excel->Workbooks->Open($excelfile); my $Sheet = $Book->Worksheets(1); $Sheet->Activate(); #Sort the file based on "Call Type" Column (F is column number 5, as A + is 0) $Excel->sort_data('WorksheetName',5,'DESC');

I have even attempted to use;

#Find Last Column and Row my $LastRow = $Sheet->UsedRange->Find({What=>"*", SearchDirection=>xlP +revious, SearchOrder=>xlByRows})->{Row}; my $LastCol = $Sheet->UsedRange->Find({What=>"*", SearchDirection=>xlP +revious, SearchOrder=>xlByColumns})->{Column};

to then try a loop type of statement. Yeah, that did not work either. Thank you for any suggestions offered I have a LONG way to go to my end results, and if I am having this many issues with a sort, I am worried about the rest of the requirments.


In reply to Sort CSV file within Excel based on specific column by jaacmmason

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (7)
    As of 2014-10-26 01:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (149 votes), past polls