将xlxs文件转换为csv

我有一个excel文件N张。 现在我想将所有的工作表转换成.csv格式使用bash shell脚本在将xlxs文件转换为.csv我需要在每个工作表中添加额外的列,最后使用公共值。 请帮忙

我同意其他评论,不能通过excel来完成吗?

示例解决scheme如果您select这种方法:

 ' Forces all variables to be declared Option Explicit Sub WorksheetLoop() ' Define variable types Dim WS_Count As Integer Dim I As Integer Dim currentWorkSheet As String Dim PathName As String ' Stop screen from flickering while code is running Application.ScreenUpdating = False ' Set WS_Count equal to the number of worksheets in the active workbook WS_Count = ActiveWorkbook.Worksheets.Count ' Begin the loop. For I = 1 To WS_Count ' Find name of the current sheet currentWorkSheet = ActiveWorkbook.Worksheets(I).Name ' Go to the current sheet Worksheets(currentWorkSheet).Activate ' Add extra column on that sheet ' Select rows in the extra column where the formula is to be added Range("D1:D10").Select ' Add the formula (example formula, multiplying previous column by 1) Selection.FormulaR1C1 = "=RC[-1]*1" ' Export to CSV ' Copy the current worksheet ActiveWorkbook.Sheets(currentWorkSheet).Copy after:=ActiveWorkbook.Sheets(currentWorkSheet) ' Rename the current worksheet Sheets(ActiveSheet.Name).Name = currentWorkSheet & "_export" ' Export the excel to csv ' Create path and name for export PathName = "" & ThisWorkbook.Path & ActiveSheet.Name & ".csv" ' Move sheet to seperate workbook Sheets(ActiveSheet.Name).Move ' Save as CSV file ActiveWorkbook.SaveAs Filename:=PathName, FileFormat:=xlCSV ' Close that CSV with the SAVE warnings surpressed Application.DisplayAlerts = False ActiveWorkbook.Close Application.DisplayAlerts = True Next I Application.ScreenUpdating = True End Sub 

要运行代码,请使用vba编辑器(快捷方式打开编辑器ALT + F11)。 打开一个新的macros,粘贴代码,然后你可以使用F8来逐行遍历每一行