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 7972967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:59:19+00:00 2026-06-04T07:59:19+00:00

I am trying to send an OOXML Excel file to the browser based on

  • 0

I am trying to send an OOXML Excel file to the browser based on the cgi.pl example in Excel::Writer::XLSX::Examples.

#!/usr/bin/perl

###############################################################################
#
# Example of how to use the Excel::Writer::XLSX module to send an Excel
# file to a browser in a CGI program.
#
# On Windows the hash-bang line should be something like:
#
#     #!C:\Perl\bin\perl.exe
#
# The "Content-Disposition" line will cause a prompt to be generated to save
# the file. If you want to stream the file to the browser instead, comment out
# that line as shown below.
#
# reverse('©'), March 2001, John McNamara, jmcnamara@cpan.org
#

use strict;
use warnings;
use Excel::Writer::XLSX;

# Set the filename and send the content type
my $filename = "cgitest.xlsx";

print "Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n";

# The Content-Disposition will generate a prompt to save the file. If you want
# to stream the file to the browser, comment out the following line.
print "Content-Disposition: attachment; filename=$filename\n";
print "\n";

# Redirect the output to STDOUT. Binmode the filehandle in case it is needed.
binmode STDOUT;

my $workbook  = Excel::Writer::XLSX->new( \*STDOUT );
my $worksheet = $workbook->add_worksheet();


# Set the column width for column 1
$worksheet->set_column( 0, 0, 20 );


# Create a format
my $format = $workbook->add_format();
$format->set_bold();
$format->set_size( 15 );
$format->set_color( 'blue' );


# Write to the workbook
$worksheet->write( 0, 0, "Hi Excel!", $format );

__END__

The file also contains characters like č š ž ć đ which are displayed like Ä Å¡ Ä Å¾ Ä !. I guess this is a problem with the encoding.

Does anybody know what could be wrong and how to fix this?

  • 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-06-04T07:59:20+00:00Added an answer on June 4, 2026 at 7:59 am

    You have an encoding problem. When you use Unicode literals in your source code, you must use the utf8 pragma and save your program source code encoded as UTF-8. This works:

    use utf8;
    ⋮
    $worksheet->write( 0, 0, "Hi Excel! č š ž ć đ", $format );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m trying to send a csv file in post request and want to
Im trying to send simple login/password parameters to my PHP file in my server
I trying to send a remote form to a different subdomain (example.domain.com) from the
i am trying to send header from a php file that is called with
Im trying to send a Docx file via this form that I made, the
I am trying to send a suggestion from my app to a php file
I`m trying to send binary file using socket. FILE *file; char *file_data; file =
I`m trying to send HTTP response to browser char *reply = HTTP/1.1 200 OK\n
I am trying to send a command that contains file path information in an
I am using node.js and trying send the .html file contains these tags: <meta

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.