Mit problem er at anvende data fra mit excel regneark i min formel i Java. Jeg kan godt udskrive min excel data i java, men jeg kan ikke bruge den i min formel. Hvad gør jeg forkert?
Mit program er nedenunder:
/* * Excel.java * * Created on 7. december 2005, 09:44 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.DriverManager;
/** * * @author Ellen Koch Nielsen */ public class Excel {
/** Creates a new instance of Excel */ public Excel() { }
/** * @param args the command line arguments */ public static void main(String[] args) { Connection c = null; Statement stmnt = null; try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); c = DriverManager.getConnection( "jdbc:odbc:vejrdata", "", "" ); stmnt = c.createStatement(); String query = "select TempC from [sheet1$] where Time2=4334;"; ResultSet rs = stmnt.executeQuery( query );
output i net beans skriver nu: init: deps-jar: Compiling 1 source file to C:\Documents and Settings\Ellen Koch Nielsen\JavaApplication40\build\classes compile: run: Temperatur: 2.1 java.sql.SQLException: No data found BUILD SUCCESSFUL (total time: 2 seconds)
Output skriver sådan: init: deps-jar: Compiling 1 source file to C:\Documents and Settings\Ellen Koch Nielsen\JavaApplication40\build\classes compile: run: 2.1 java.sql.SQLException: No data found BUILD SUCCESSFUL (total time: 0 seconds)
/* * Excel.java * * Created on 7. december 2005, 09:44 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.DriverManager;
/** * * @author Ellen Koch Nielsen */ public class Excel {
/** Creates a new instance of Excel */ public Excel() { }
/** * @param args the command line arguments */ public static void main(String[] args) { Connection c = null; Statement stmnt = null; ResultSet rs = null; try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); c = DriverManager.getConnection( "jdbc:odbc:vejrdata", "", "" ); stmnt = c.createStatement(); String query = "select TempC from [sheet1$] where Time2=4560;"; rs = stmnt.executeQuery( query );
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.