LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-23-2021, 05:12 PM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
Batch print Excel files with lp


I have 33 Excel files I want to print.

They are all just 1 page A4 size.

I was hoping I could use the script below in bash, but I get this error from lp:

Quote:
lp: Unsupported document-format "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".
I don't really want to open each file and then click print.

Any tips please? Maybe convert to PDF??

Code:
#! /bin/bash
echo "This script should print all the files in a given directory."
echo "Easiest is go to that directory first."


XLfiles="/home/pedro/winter2021/20EAP/individual_stats/*.xlsx" # local machine
# batch print Excel files

for X in $XLfiles;
do
echo "This is one of the files:"
printf $X;
printf "\n";
echo "Now sending the file to the printer ... "
lp -d "EPSON-L380-Series" $X;
done

echo "All files sent to the printer!"
echo "All done!"
 
Old 11-23-2021, 06:11 PM   #2
JohnHendry
Member
 
Registered: Apr 2020
Location: Sydney, Australia
Distribution: Crux Linux, LFS, Artix, source packages (64-bit PC)
Posts: 39

Rep: Reputation: Disabled
Perhaps installing gnumeric would register the xlsx type. Or some open office type spreadsheet app. Or you could put open file and print in your batch file.

Last edited by JohnHendry; 11-23-2021 at 06:13 PM.
 
1 members found this post helpful.
Old 11-23-2021, 06:26 PM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,375

Rep: Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754
Have you tried this technique of converting from Excel format to PDF format and then printing?
 
1 members found this post helpful.
Old 11-24-2021, 12:21 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
^Either that or ssconvert (which is part of Gnumeric).
 
1 members found this post helpful.
Old 11-24-2021, 08:22 PM   #5
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Thanks for your replies!

I had never heard of gnumeric or ssconvert before, but I installed them.

I used the libreoffice approach,

Quote:
libreoffice --headless --convert-to pdf *.xlsx
then lp with the pdfs, worked perfectly.

but I will look into gnumeric. I already installed it.

Thanks for your advice!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to write a batch file in linux?and what are batch(.bat) file benefits? karthilin Linux - Newbie 8 10-15-2012 02:10 PM
Reading one EXCEL(.xls) file and writing to other EXCEL(.xls) file vijay mishra General 6 04-23-2012 07:53 PM
How to copy Arabic data from excel fiel to another excel file in PERL? David the H. Linux - Newbie 0 04-23-2012 09:24 AM
Convert from XML in excel format to Excel XLS file CPAN module Perseus Programming 9 10-14-2011 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration