Save individual Excel sheets as CSV

前端 未结 2 1294
我在风中等你
我在风中等你 2020-12-31 15:01

I need to parse Excel work sheets. Now I save each individual work sheet as .csv and it works great. I use OpenCSV to parse the files etc. but to create those .csv files are

2条回答
  •  被撕碎了的回忆
    2020-12-31 16:05

    Very roughly,

    Dim ws As Worksheet
    
    For Each ws In ActiveWorkbook.Worksheets
        ws.SaveAs "C:\docs\" & ws.Name & ".csv", xlCSV
    Next
    

    This does not include any error coding nor does it make allowances for sheet names that will lead to illegal file names. It all depends on how robust you need the whole thing to be.

提交回复
热议问题