如何使用批处理脚本从Excel文件中清除内容?
我试过这个,但它不起作用
type nul > test.xlsx
答案 0 :(得分:0)
excel文件不是文本文件,即使是空文件也包含一些二进制元数据。 试试这个(在第二行你可以设置新文件的名称):
@echo off
set newFile=new.xslx
certutil -f -decode "%~f0" "%newFile%"
exit /b %errorlevel%
-----BEGIN CERTIFICATE-----
UEsDBBQABAAIAGJivkClq/f+WgEAADMEAAATAAAAW0NvbnRlbnRfVHlwZXNdLnht
bKyTTU7DMBCF9z2F5S1K3LJACCXtgp8ldFEOYOxJY9WxLY9b2rOx4EhcgUkCSEFV
aVWySBRF897zNy8fb+/FbNtYtoGIxruST/IxZ+CU18YtS/68eMiuOcMknZbWOyj5
DpDPpqNisQuAjIYdlrxOKdwIgaqGRmLuAzj6UvnYyESvcSmCVCu5BHE5Hl8J5V0C
l7LUavDpiNFVPFGIaDSwuYzpUTbkJbZWJJKE/j7JSZSz2366DVByGYI1SiZKLzZO
/7LOfFUZBdqrdUOGeSd20aqIw66YdhbwbD8MEaTGGiA1Nu9FB/Z3UMm1Tex+S0D6
FUSweNohv9jmNNmBwNoE/MvmMMojEL36uHrxfvXfkFpYeSONG5xgXztorfPoAwoq
wdkpoN2ABp0FkoSYDAwR7gtA9WwpdPtF0T3O7+iwMz/6x9NQPsLpOL5L1E7vYVCI
7oeffgIAAP//AwBQSwMEFAAEAAgAYmK+QKLZLrD/AAAAXgIAAAsAAABfcmVscy8u
cmVsc4ySTU7DMBCF9z2FNftm0iIhhJJ0UyF1h1A4wGBPfpTEY9kG0rOx4EhcAbNA
EAnaejee5/e+Gfnj7b3YzdOoXtiHXmwJmywHxVaL6W1bwmN9t74BFSJZQ6NYLuHI
AXbVqnjgkWJ6E7reBZVMbCihi9HdIgbd8UQhE8c2dRrxE8VU+hYd6YFaxm2eX6P/
7QHVSqWzMFYHU4I/mCtQ9dGl9PMB0jS95r3o54lt/CMHeY5sDZu18wnQxz5NpGry
LccSjOj7dB2QnMsSO+AJrO3lWP/PjRNHMhQJ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度文件替换文件,有效删除数据。
答案 2 :(得分:0)
检查以下文件夹(might vary depending on your OS and Excel version):
C:\Users\All Users\Microsoft\Windows\Templates
%APPDATA%\Microsoft\Windows\Templates
%APPDATA%\Microsoft\Excel\XLSTART
%useprofile%\Templates
可能有一个Excel模板,例如(否则,create i t)
Book.xlt
(.xltx
/ .xltm
)或Sheet.xlt
(.xltx
/ .xltm
)。我们假设有一个文件%useprofile%\Templates\Sheet.xltx
然后下一个命令应该做的伎俩:
copy /Y /B "%useprofile%\Templates\Sheet.xltx" test.xlsx