如何最有效地自动执行重复的Excel任务?

0xC*_*ABE 1 excel perl automation

我想使用Perl自动执行Excel以执行以下任务:

For a list of Excel .xls files, do the following:
  Open the file
  Set Format to CSV
  Save the file under the original filename and directory, but replace the extension "xls" with "csv"
  Close the file
End
Run Code Online (Sandbox Code Playgroud)

我找到了如何打开文件,甚至如何保存它们.我没有找到如何将fileformat/save更改为其他格式.不应弹出用户对话框,应完全自动化.我可以自己生成的Excel文件列表,参数化的"查找"或者"dir"就足够了.

Pie*_*ter 5

如果您使用Excel自动化,Excel本身就是一个很好的帮助.使用VBA环境(Alt + F11)获取要使用的Excel对象的帮助.

对象浏览器(F2)非常有价值.

Workbook.SaveAs([Filename], [FileFormat], [Password], [WriteResPassword], [ReadOnlyRecommended], [CreateBackup], [AccessMode As XlSaveAsAccessMode = xlNoChange], [ConflictResolution], [AddToMru], [TextCodepage], [TextVisualLayout], [Local])
Run Code Online (Sandbox Code Playgroud)

在对象浏览器中搜索CSV将显示Excel常量及其值,因为您可能无法在Perl中使用这些Excel常量.