#!/bin/sh # Useful for inspecting the relevant parts of an xlsx output. An xlsx # file is essentially a zip file with a bunch of .xml files. This extracts # the zip and pretty prints one of the given xml files set -e if [ "X$1" = "X" ]; then echo "Usage: $0 XLSX_FILE [SUB_XML_FILE]" >&2 exit 1 fi WORK_DIR=`mktemp -d` cp $1 $WORK_DIR/$1.zip pushd $WORK_DIR unzip $1.zip if [ "X$2" = "X" ]; then xml_files=`find . -type f -iname '*.xml'` else xml_files=`find . -type f -iname '*.xml' | grep -i $2` fi for f in $xml_files; do echo "\n-------------------------- $f --------------------------\n" xmllint --format $f done function cleanup { rm -rf $WORK_DIR popd } trap cleanup EXIT