Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Retrieve from Microsoft Excel document for CodeGenerator?

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Retrieve from Microsoft Excel document for CodeGenerator?

    Basically, I have a code generator that I've made in java (that generates code for a Visual Basic Quiz program I'm making) that I would like to make more effecient by using it with a database.

    If anyone is interested, this is what it looks like:
    import java.io.*;
    	import java.io.FileNotFoundException;
    	import java.io.FileOutputStream;
    	import java.io.PrintStream;
    	import java.util.Vector;
    	public class codegen {
    		static int qnum = 1;
    		static int snum = 1;
    	  public static void main(String[] a) {
    	    Vector victor;
     
    	    int size = 10;
     
    	    victor = new Vector(size);
    	    for (int i = 0; i < size; i++)
    	      victor.addElement(new Integer(i));
     
    	    try {
    	      PrintStream out = new PrintStream(new FileOutputStream(
    	          "OutFile.txt"));
    	      for (int i = 0; i < size; i++)
    	    	  while (snum <= 15){
    	    		  if (qnum <= 71){	
    						out.println("ElseIf Randq = " + qnum + " And sec" + snum + "(" + qnum + ") < 3 Then");
    						out.println("answrstrng = ''");
    						out.println("If usrinput = answrstrng Then");
    						out.println("Correct.Text += 1");
    						out.println("sec" + snum + "(" + qnum + ") += 1");
    						out.println("Else");
    						out.println("Incorrect.Text += 1");
    						out.println("sec" + snum + "(" + qnum + ") -= 1");
    						out.println("canswer.Text = answrstrng");
    						out.println("End If");
    						++qnum;
    					}
    					else {
    						qnum = 1;
    						snum++;
    					}
    	    	  }
    	      out.close();
     
    	    } catch (FileNotFoundException e) {
    	      e.printStackTrace();
    	    }
    	  }
    	}

    It would make things a lot easier for me, and make the code generator complete, if where it says
    out.println("answrstrng = ''");
    i could replace the '' with text from the cell of an excel document. For example, if cell A1 said "Fiji" in the document, it would print answrstrng = "fiji".

    I don't really know anything about Java databases, so if there's another way I should do this outside of microsoft excel, information on that would help me too.

    Thanks!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,354
    Thanks
    182
    Thanked 832 Times in 775 Posts
    Blog Entries
    5

    Default Re: Retrieve from Microsoft Excel document for CodeGenerator?

    I'm confused as to what you are asking...do you wish to use Excel, or a relational database (quite different things)? For excel, you can use 3rd party libraries such as Apache POI to read and write the file. For a relational database, you should learn SQL (and there are many options to choose from: Derby, MySQL, PostgreSQL, etc...)

Similar Threads

  1. Retrieve coordinates of other windows
    By Knox in forum AWT / Java Swing
    Replies: 1
    Last Post: April 10th, 2011, 03:03 PM
  2. [HELP] How can I retrieve attribute/method?
    By k4it0xtr3me in forum Object Oriented Programming
    Replies: 0
    Last Post: January 21st, 2011, 02:18 AM
  3. [SOLVED] Problem trying to retrieve a file from ftp server
    By alexdd1987 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 16th, 2010, 06:27 PM
  4. Microsoft Office Communicator through java
    By balaji in forum Java Theory & Questions
    Replies: 1
    Last Post: September 22nd, 2010, 02:36 PM
  5. Replies: 6
    Last Post: August 30th, 2009, 05:31 AM