aboutsummaryrefslogtreecommitdiffstats
path: root/.mutt/excel2text.sh
blob: c3d0f1403a0b6b88d39e31cc1409b0ed4196a09f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
#
# excel2text - convert MS Excel files to ASCII text
#
# Written by Gary Johnson <garyjohn@spk.agilent.com>.
#
# Modification History:
#   2003-02-19
#       Changed the name xlHtml to xlhtml to match the xlhtml-0.5
#       release.

prog=${0##*/}

if [ $# -ne 1 ]
then
    echo "Usage: $prog file" >&2
    exit 2
fi

xlhtml -te "$1" |
perl -pe 's/>-{21,}</><HR></g' |	# This replaces long lines of
					# hyphens with HTML <HR> tags so
					# that these lines adapt to the
					# width of the cell.  "21" is a
					# value that works for the
					# tables I'm sent.
w3m -dump -T text/html |
perl -pe '
	s/\xa0/ /gs;			# Change A0 spaces to ASCII
					# spaces.
'