PreviousNext
Help > Programming with LAUNCHER Office > Java classes > Use examples > 7) LNCTOXLS : Microsoft SQL Server
7) LNCTOXLS : Microsoft SQL Server

In this example, the database has the following characteristics :

         Type DB : Microsoft SQL Server

         Database server address  : 192.168.1.7

         Port number of the database server : 1433

         Database user : sa

         Database user password : aura

         Database name : master

         SQL query : select * from dbo.spt_values

 

The command LNCTOXLS is used to generate the following Excel file:
C:\temp\test2.xls

 

 

     String Destination="C:\\temp\\test2.xls";

     DataSource myDataSource = new DataSource();
     myDataSource.setType("sqlserver");
     myDataSource.setSrvAddr("192.168.1.7");
     myDataSource.setPort("1433");
     myDataSource.setUser("sa");
     myDataSource.setPassword("aura");
     myDataSource.setDBName("master");
     myDataSource.setQuery("select * from dbo.spt_values");

     LNCTOXLS myLNCTOXLS = new LNCTOXLS();
     myLNCTOXLS.setToXls("*new");
     myLNCTOXLS.setToSheet("*NONE");
     myLNCTOXLS.setToName("*NONE");
     myLNCTOXLS.setColPref("*NONE");
     myLNCTOXLS.setAutoFmt("*NONE");
     myLNCTOXLS.setAutoFit("true");
     myLNCTOXLS.setFmtCells("false");
     myLNCTOXLS.setAddColH("false");
     myLNCTOXLS.setShowDoc("true");
     myLNCTOXLS.setSourceData(myDataSource);
     myLNCTOXLS.setLNCSrvAddr("192.168.1.9");
     myLNCTOXLS.setSavFmt("*XLS");
     myLNCTOXLS.setSavDoc(Destination);

     myLNCTOXLS.execute();