Eu fiz um script bash fazendo isso no OS X, caso algum de vocês gostaria de fazer isso:
Você usa assim:
backward_forecast workbook.xlsx forecast_number
Script:
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo "Usage: backward_forecast workbook.xlsx forecast_number"
exit 1
fi
extension="${1##*.}"
if [[ "$extension" != xlsx ]]
then
echo "Unknown extension: $extension"
exit 2
fi
OLD_IFS="$IFS"
IFS=$'\n'
charts=( $(zipinfo -1 "$1" 2> /dev/null | grep '^xl/charts/.*\.xml') )
IFS="$OLD_IFS"
chart_files="${#charts[@]}"
case "$chart_files" in
0)
echo "No charts found in $1."
exit 3
;;
1)
process_files=( "${charts[0]}" )
;;
*)
options=""
i=0
for c in "${charts[@]}"
do
i=$(($i+1))
tmp="${c##*/}"
options+="$i) ${tmp/.xml}"$'\n'
done
while true
do
echo "Multiple chart files found."
echo "Please select the chart you want to change:"
echo
echo "$options"
echo
read -p "Chart number (* = all): " input
if [[ "$input" == "*" ]]
then
process_files=( "${charts[@]}" )
break
elif [[ "$input" -gt 0 && "$input" -le "$chart_files" ]]
then
input=$(($input-1))
process_files=( "${charts[$input]}" )
break
else
clear
echo "Bad selection number!"
echo
fi
done
;;
esac
cd /tmp
mkdir -p xl/charts
for f in "${process_files[@]}"
do
unzip -p "$1" "$f" | sed 's/<c:backward val="[^"]*"\/>/<c:backward val="'"$2"'"\/>/' > "$f"
zip -q "$1" "$f"
rm -f "$f"
done