Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Linking excel file with a application tool using swing
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Abhinav Mishra
Linking excel file with a application tool using swing
2 Answer(s)      3 years and 5 months ago
Posted in : Java Beginners


I have to link an excel file with my application software using java swing.As soon as i click on the link button a window should open for selecting the excel file(just like when we search for file to upload)and i should be able to select the excel file and link it with the tool.The excel file will contain some questions for survey.After linking the tool must be able to take those questions and generate a template containing the questions.please help me with the code!


Advertisement
View Answers

July 27, 2011 at 5:10 PM


import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.filechooser.*;

public class SelectFile extends JFrame{
public static void main(String[]args){
                JFrame frame = new JFrame();
                frame.setLayout(null);

                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setSize(400, 100);
                Container container = frame.getContentPane();
                container.setLayout(new GridBagLayout());

                final JTextField text=new JTextField(20);
                JButton b=new JButton("Select");
                text.setBounds(20,20,120,20);
                b.setBounds(150,20,80,20);

                b.setText("<html><font color='blue'><u>Select File</u></font></html>");
                b.setHorizontalAlignment(SwingConstants.LEFT);
                b.setBorderPainted(false);
                b.setOpaque(false);
                b.setBackground(Color.lightGray);
                b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e){
                            JFileChooser fc = new JFileChooser();
                            fc.addChoosableFileFilter(new OnlyExt());

                            int returnval = fc.showOpenDialog(null);
                            if (returnval == JFileChooser.APPROVE_OPTION) {
                            File file = fc.getSelectedFile();
                            text.setText(file.getPath());
                            } 
                        }
                });
                container.add(text);
                container.add(b);
                frame.setVisible(true);
        }
}
    class OnlyExt extends javax.swing.filechooser.FileFilter{
        public boolean accept(File file) {
    if (file.isDirectory()) return false;
    String name = file.getName().toLowerCase();
    return (name.endsWith(".xls"));
    }
    public String getDescription() { return "Excel ( *.xls)"; }
    }


July 27, 2011 at 5:41 PM


Thanks for the code.But this code is only able to open a Jpanel to select the file.After I select the file nothing is happening.I wanted to be able to generate a template based on the questions that are in the excel file(linking the file).could you please help me with this?



Related Tutorials/Questions & Answers:
Linking excel file with a application tool using swing
Linking excel file with a application tool using swing  I have to link an excel file with my application software using java swing.As soon as i click on the link button a window should open for selecting the excel file(just like
Linking an Excel File with the Application tool
Linking an Excel File with the Application tool  I have to link an excel file with a application software which I am developing.I have this code... on the questions that are in the excel file like extracting the questions from the excel file
Advertisements
How to link a excel file with a application software using java swing
How to link a excel file with a application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
How to link a excel file with a application software using java swing
How to link a excel file with a application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
How to link an excel file with the application software using java swing
How to link an excel file with the application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
swing application to import a object in a excel
swing application to import a object in a excel  Hi sir, I want to make a swing application where I can import a object in a cell of a excel... 'create from file' window>browse (this browse path I want to give inside the swing
Import object in Excel using java swing
Import object in Excel using java swing  Hi sir, I want to make a swing application where I can import a object by clicking a button. I am using.... The details of the excel operation which i want to do by one click: in excel its
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i am try to develop a tool which reads from a excel file and then appends the same... used JDBC ODBC to read from excel file. i am not able to append it using
Excel file wriring using java
Excel file wriring using java  i have one predefined bill format in excel i want to append values in it using java apche POI or Jexcel i tried it but it overwrites file and lost previous contents what can i do
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
Reading .doc file using swing
Reading .doc file using swing  Sir, Could U Please Tell me the Way To Read .doc file in java using swing,with code
downloading excel file using Java and springs
downloading excel file using Java and springs  I need to find out how to download an excel file using the spring framework in java. Please help me out as I am new to springs and its urgent
To read & write a excel file using the core java
To read & write a excel file using the core java  Hai, I'm new to JavaProgram.But now i need java program to read & write a excel file so, can anyone help me to learn the above mentioned topic(link for the portion
How to generate reports dynamically using ireports tool in a web application?
How to generate reports dynamically using ireports tool in a web application?  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application?
How to generate reports dynamically using ireports tool in a web application?  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application?
How to generate reports dynamically using ireports tool in a web application?  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application?
How to generate reports dynamically using ireports tool in a web application?  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
How to generate reports dynamically using ireports tool in a web application
How to generate reports dynamically using ireports tool in a web application  Hi all, As part of my web application , i need to generate reports dynamically using ireport tool.. i have installed the tool and its working fine
 

 

 

DMCA.com