Q:

inserting data into excel using java

I am buliding a stand alone application using java swing. and excel 2007 sheet as the backend for storing my data. There are 15 columns in the excel sheet. I am able to insert data into it with just 5 columns. But it shows "syntax error" when i try inserting 15 columns. Is there any limit on the the number of columns that can inserted at a time? or is there any other syntax for lengthy records? I am new to java. so kindly help me out. Thanks in advance :) i have posted the part of the coding
 try
                       {

                         String value1=t1.getText();

                         String value2=(String)c6.getSelectedItem();

                         String value3=t3.getText();

                         String value4=t4.getText();

                         String value5=t5.getText();

                         String value6 = (String) c4.getSelectedItem(); 

                         String value7=t7.getText();

                         String value8=t8.getText();

                         String value9 = (String) c1.getSelectedItem(); 

                         String value10 = (String) c2.getSelectedItem(); 

                         String value11 = (String) c5.getSelectedItem(); 

                         String value12 = (String) c3.getSelectedItem(); 

                         String value13=t13.getText();

                         String value14=t14.getText();

                         String value15=t15.getText();

           //connection to the database          

                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
               Connection con=DriverManager.getConnection("jdbc:odbc:testingApp");

          //Execute some sql and load the records into the resultset
                  Statement st=con.createStatement();
                String q = "insert into [sheet1$] (CRN,CR_NUM,SOW_N,PSM,LBG,TYPE,VALUE,REMARKS,STATUS,APPROVAL,PLATFORM,MODEL,START_DATE,END_DATE,CUM_VALUE) values ('"+value1+"','"+value2+"','"+value3+"','"+value4+"','"+value5+"','"+value6+"','"+value7+"','"+value8+"','"+value9+"','"+value10+"','"+value11+"','"+value12+"','"+value13+"','"+value14+"','"+value15+"')";
                 int ds = st.executeUpdate(q);
                 System.out.println("Inserted Sucessfully...!!!");

                  /* t1.setText(null);
                    c6.addItem(null);
                    t3.setText(null);
                    t4.setText(null);
                    t5.setText(null);
                    c4.addItem(null);
                    t7.setText(null);
                    t8.setText(null);
                    c1.addItem(null);
                    c2.addItem(null);
                    c5.addItem(null);
                    c3.addItem(null); 
                    t13.setText(null);
                    t14.setText(null);
                    t15.setText(null); */
                    }catch(Exception e)
                       {
                           System.out.println(e.getMessage());
                        }
                    }

} 

A:

If you want to have xls/xlsx format then as sp00m sai, Apache POI is best solution,
if you want to have csv file, then just create text file and write there data separating columns with comma and rows with "\n" character

