Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3964260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:18:47+00:00 2026-05-20T03:18:47+00:00

Originally I tried to open a XML file with Excel. But as this takes

  • 0

Originally I tried to open a XML file with Excel. But as this takes ages I parsed the XML myself into a Tab delimited text file. I thought I found the correct syntax in the internet. I tried below code using the values I recorded with an Excel Macro. I have an 18 column Tab delimited file. The error occures in the last line of below code when calling “Worksheets” Method.

Error message:
Can’t call method “Worksheets” without a package or object reference at ./PostProcessingDev.pl line 70.

use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
Win32::OLE->Option(Warn => 3);

use strict;

my $Excel;
my $Sheet;
my $Workbook;


$Excel = CreateObject OLE "Excel.Application";

$Workbook =  $Excel->Workbooks->OpenText({Filename =>"$inSelf->{'TXT'}",
  Origin => xlMSDOS,
  StartRow => 1,
  DataType => xlDelimited, 
  TextQualifier => xlDoubleQuote, 
  ConsecutiveDelimiter => "False", 
  Tab => "True",
  Semicolon => "False",
  Comma => "False",
  Space => "False",
  Other => "False",
  FieldInfo => [[1, xlTextFormat],
    [2, xlTextFormat],
    [3, xlTextFormat],
    [4, xlTextFormat],
    [5, xlTextFormat],
    [6, xlTextFormat],
    [7, xlTextFormat],
    [8, xlTextFormat],
    [9, xlTextFormat],
    [10, xlTextFormat],
    [11, xlTextFormat],
    [12, xlTextFormat],
    [13, xlTextFormat],
    [14, xlTextFormat],
    [15, xlTextFormat],
    [16, xlTextFormat],
    [17, xlTextFormat],
    [18, xlTextFormat]],
  TrailingMinusNumbers => "True"});

$Sheet = $Workbook->Worksheets(1);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:18:47+00:00Added an answer on May 20, 2026 at 3:18 am

    Do you really have to parse TSV using Excel? If there is nothing fancy in your files, you might well use something like this:

    my $file = 'some tsv file';
    {
        open my $in,"<",$file  or die "$file: $!";
        while(<$in>) {
            chomp;
            my @cols = split /\t/;
            # do something with columns in @cols array
        }
    }
    

    If Excel is needed for a reason I cannot see, the problem is that OpenText method returns True/False and not Workbook object. This works:

    use strict;
    
    use Win32::OLE;
    use Win32::OLE::Const 'Microsoft Excel';
    use Data::Dump;     # for dd
    
    Win32::OLE->Option(Warn => 3);
    
    my $Excel = Win32::OLE->new("Excel.Application");
    $Excel->Workbooks->OpenText({
        Filename             => 'enter the full path to file',
        Origin               => xlMSDOS,
        StartRow             => 1,
        DataType             => xlDelimited,
        TextQualifier        => xlDoubleQuote,
        Tab                  => "True",
        TrailingMinusNumbers => "True"
    });
    
    my $Sheet = $Excel->ActiveWorkbook->Worksheets(1);
    my $Data = $Sheet->UsedRange()->{Value};
    
    dd $Data;    # arrayref (rows) of arrayrefs (columns)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I originally asked this question on RefactorMyCode , but got no responses there... Basically
Originally posted on Server Fault , where it was suggested this question might better
I have a Excel .CSV file I'm attempting to read in with DictReader. All
How do I open a new window in javascript properly? I've tried: <a href='javascript:window.open(testing.html,mywindow,menubar=0,resizable=1,width=200,height=500,left=0,top=0);'
I'm using a open-source library for i2c bus actions. This library frequently uses a
After reading from an existing file with 'ugly' XML and doing some modifications, pretty
I have a file, which is in XML format (consists just of root start
I have written a converter that takes openstreetmap xml files and converts them to
I tried my best to search for the answer, but couldn't fine something that
I am currently using VBA code which was originally intended for an excel document.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.