这毫无意义。我可以在 Windows 上的 Excel 2010 中执行此操作,但不能在 OS X 上的 Excel 2011 中执行此操作。
我使用的工作簿:http://cl.ly/Ewfe
截图:
答案1
我在 OS X 上编写了一个 bash 脚本来执行此操作,以便你们中有人愿意这样做:
你可以像这样使用它:
backward_forecast workbook.xlsx forecast_number
脚本:
#!/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