tags:

views:

358

answers:

4

This works:-

for /F  "tokens=4 delims=    skip=1" %%x in (myfile.txt) DO echo %%x

But not this:-

for /F  "tokens=4 delims=    skip=1" %%x in (myfile.xls) DO echo %%x

How can i read xls without converting to tab saperated?

XLS = Excel file

A: 

Whether you're talking about the binary .xls format or XML, parsing in a Windows batch file is basically going to be impractical. You should use a more appropriate tool. The closest thing to a Windows batch file which will be able to cope with this is probably PowerShell.

Batch files are okay for pretty simple tasks, but when you need to do anything with a bit more complexity, you should look to use something more powerful. (I'm not particularly fond of Windows batch files in the first place compared with, say, bash scripts - but sometimes they're the easiest way to get things done.)

Jon Skeet
and also vbscript
ghostdog74
+1  A: 

if you want to do it with batch, for whatever reasons, you can export and save your xls file to comma separated (csv), then use delim=, in your batch for loop.

ghostdog74
A: 

If you have Excel installed, you can easily create a vbscript or PowerShell script for the task. The Windows command shell interpreter really isn't up to the task of parsing Excel files.

VBScript:

Set objExcel = CreateObject("Excel.Application")

PowerShell:

a = New-Object -comobject Excel.Application
brianegge