-1

There is a requirement in my project to automate some SQL queries and i did but after that one user came and ask that we do not want 2 separate .csv file we want 1 .csv file with multiple sheets

For eg. suppose there 2 .csv files "Text1.csv" and "Text2.csv" and we are sending this to users but they are coming back asking to do it like a "Text.csv" file with "sheet1" and "sheet2" sheets.

I have been using below

@echo off
cls
@echo *****************************Reports****************************
@echo.

sqlcmd -h-1 -S database -E -i "loc.sql" -o "loc2.csv"

sqlcmd -h-1 -S database -E -i "loc1.sql" -o "loc2.csv"

@echo Report is generated
@echo.

Note: I can not use any 3rd party tool like java or jscripts, neither i can use Visual studio for VBS, i have only option with batch cmd file

PS. if there is another kind of script that can write as a batch file without any need of 3rd party tool that will be great

1 Answer 1

0

This isn't possible as the CSV format doesn't support multiple sheets (presuming that you are trying to view the file in excel).

The most you can do with a batch script is append one file onto another

copy File1+File2 NewFile
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for responding @zhqiat.... but this way.. i can not resolve the query of user, we were sending excel(.xlsx) files before this and in that we were putting data manually in tabs. so now if i am automating they want the same and exact, the way it was
Or is there any way that i can create a excel file(.xls or .xlsx) through batch command?
a csv file is a textfile only. There are no tabs. If you want tabs, you can't use csv files. You have to use "real" Excel files xls(x). But you can't process Excel files with batch, you have to use some other language (powershell might do the trick)
+1 to @Stephan XLSX files have to be created via a more high level language. You can try to use a batch script to call a vba script which creates your excel file.
Vbscript and Powershell can both modify excel files.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.