Reputation: 14741
I have the below script to execute SQL file.
<target name="dataExcel" >
<sql classpath="/ojdbc14.jar" driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"
userid="scott"password="tiger"
src="/generateData.sql" />
</target>
Is it possible to spool data to Excel file? I need to automate SQL data export to Excel using script.
Edit 1
<project name="xlsx task">
<taskdef name="xlsx"
classname="net.sourceforge.ant4x.biz.ms.XlsxTask"
classpath="PATH/TO/ant4x.jar"/>
<target name="xlsx">
<xlsx file="/path/to/file.xlsx">
<clone sheet="The_Sheet_To_Clone" rows="1-10">
<column name="C" mergewithnext="true">
<prefix value="[COLUMN C]EOL"/>
</column>
<column name="D">
<prefix value="EOL[COLUMN D]EOL"/>
</column>
<column name="E"/>
</clone>
</xlsx>
</target>
</project>
Upvotes: 1
Views: 100
Reputation: 21192
sql task has output
property where you can specify csv
file which will contain SQL results.
If you want to generate xlxs file you can use Txt2XlsxTask where you specify the input file obtained from sql task and xlsx output file.
Upvotes: 1