-5

I was asked to look for a procedure that convert an Excel file into a CSV one, however I have no knowledge on .bat. I've seen some people doing so with some commands and I would like to know if I can do the same but important: skipping the first five rows of the file.

I would appreciate any help you give me.

Squashman
  • 13,649
  • 5
  • 27
  • 36
Steven Guerrero
  • 876
  • 8
  • 17
  • Have you tried just plain 'Save as CSV' from Excel. will that be okay? Or you want it scripted? – MEdwin Oct 11 '18 at 16:03
  • I need it to be scripted, yes. – Steven Guerrero Oct 11 '18 at 16:05
  • You need to use a more suitable language, such as [PowerShell](https://stackoverflow.com/q/27293481), or [VBS](https://stackoverflow.com/q/1858195). Alternatively use an executable utility designed for the task. – Compo Oct 11 '18 at 16:27

1 Answers1

-1

A very easy way, is to create a vbs script. Paste the below into a notepad and save as XlsToCsv.vbs. Make sure you give the full path of sourcexlsFile and also destinationcsvfile

To use: XlsToCsv.vbs [sourcexlsFile].xls [destinationcsvfile].csv

 if WScript.Arguments.Count < 2 Then
    WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
    Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.Sheets(1).Range("1:5").EntireRow.Delete  'this removes the first five rows everytime
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"
MEdwin
  • 2,940
  • 1
  • 14
  • 27
  • 1
    The problem with this is that I must avoid in the possible to access the Excel file. And yet, there's the problem that I need to skip that first five rows everytime I execute it. – Steven Guerrero Oct 11 '18 at 16:18
  • who is down votting without comments? Are you being helpful here? I have personally tried this code and it works. – MEdwin Oct 12 '18 at 08:29
  • I don't know who is down voting, but this worked for me too – Steven Guerrero Oct 12 '18 at 14:41