Hello,

This is my code done with help of many Monks.

#!/usr/bin/perl -w use warnings; #use strict; use Spreadsheet::Read 'ReadData'; use Encode 'decode'; use XML::LibXML; use HTML::Parser; use utf8; use File::Basename; $converted_dir = "converted_files"; # Source file and path are taken as script parameter if (@ARGV) { $full_source_file_path = $ARGV[0]; } else { die (" ! Please, enter file name as script parameter. \n See READM +E.txt for mor details"); } # Parse @ARGV, get path and file from script parameter ($source_file_name, $source_file_path, $source_file_suffix) = filepars +e($full_source_file_path, qr/\.[^.]*/); # Define all files and paths $source_file = "$source_file_name$source_file_suffix"; # Create folders for logs and converted files chdir ($source_file_path); mkdir ($converted_dir); # Output files get names after source file $xml_file = ("$source_file_name\_resulted.xml"); # Files + folders knocked into variables $xml = "$converted_dir/$xml_file"; no warnings; #my $INFILE = 'TestPGR.xlsx'; my $ENCODING = 'MacRoman'; #my $OUTFILE = 'TestPGR.xml'; my %FIELDS = ( 1=>'docid', 2=>'title', 3=>'version', 4=>'revision', 5=>'node_order', 6=>'description', 7=>'status', 8=>'type', 9=>'expected_coverage', ); my $book = ReadData($source_file, rc=>1, cells=>0, parser => "xlsx"); my $sheet = $book->[1] or die "Book doesn't have a sheet 1"; my $doc = XML::LibXML::Document->createDocument('1.0', 'UTF-8'); my $reqs = $doc->createElement('requirements'); $doc->setDocumentElement($reqs); #my $pp = new HTMLStrip; for my $r ( $sheet->{minrow}+1 .. $sheet->{maxrow} ) { my $req = $doc->createElement('requirement'); for my $c ( $sheet->{mincol} .. $sheet->{maxcol} ) { next unless exists $FIELDS{$c}; my $val = $sheet->{cell}[$c][$r]; if ($c ==6) { $val =~ s/\n/<br \/>/g; } my $node = $doc->createElement($FIELDS{$c}); $node->appendText($val); $req->appendChild($node); } $reqs->appendChild($req); } $doc->setEncoding('MacRoman'); $doc->toFile($xml,1);

This is an example of my file to test

https://drive.google.com/file/d/1VGBDtdK9kP6OBVXvTT_oxyh2g45yfsvC/view?usp=sharing

When I launch it, even none file (in and out are opened), I have this error

MBPPGR:Exigence sapfinance$ perl essai2.pl TestPGR.xlsx i18n error : output conversion failed due to conv error, bytes 0x00 0x +65 0x6D 0x70 I/O error : encoder error
Have you an idea of issue?

In reply to [Solved]i18n error : output conversion failed due to conv error by Balawoo

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!
  • 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:
    & &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.