Home Answers Viewqa Java-Beginners excel parsing and print data in the form of table

 
 


sathish gollapally
excel parsing and print data in the form of table
3 Answer(s)      a year and 3 months ago
Posted in : Java Beginners

my reqment is i have to parse the excel and i need to print the data in the table by using swing jtable or else ....can u give the solution please....

View Answers

March 1, 2012 at 5:04 PM


import java.io.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

public class ExcelToJtable {
 public static void main(String[] args) {

  Vector headers = new Vector();
  Vector data = new   Vector();

    File file = new File("c:/data.xls");
    try {
    Workbook workbook = Workbook.getWorkbook(file);
      Sheet sheet = workbook.getSheet(0);
      headers.clear();
      for (int i = 0; i < sheet.getColumns(); i++) {
        Cell cell1 = sheet.getCell(i, 0);
        headers.add(cell1.getContents());
      }
      data.clear();
      for (int j = 1; j < sheet.getRows(); j++) {
      Vector d = new Vector();
      for (int i = 0; i < sheet.getColumns(); i++) {
      Cell cell = sheet.getCell(i, j);
          d.add(cell.getContents());
      }
      d.add("\n");
      data.add(d);
     }
    }
    catch (Exception e) {
         e.printStackTrace();
    }
    JTable table = new JTable();
    DefaultTableModel model = new DefaultTableModel(data,headers);
    int tableWidth = model.getColumnCount()* 150;
    int tableHeight = model.getRowCount()* 25;
     table.setPreferredSize(new Dimension(tableWidth, tableHeight));
     table.setModel(model);
     table.setAutoCreateRowSorter(true);
     model = new DefaultTableModel(data, headers);
     table.setModel(model);
     table.setEnabled(false);
     table.setRowHeight(25);
     table.setRowMargin(4);

     JScrollPane scroll = new JScrollPane(table);
     JFrame f=new JFrame();
     f.add(scroll);
     f.setSize(600, 600);
     f.setVisible(true);
  }
}

March 1, 2012 at 5:07 PM


For the above code, you need JExcel API.

Download JExcel API


March 1, 2012 at 6:50 PM


Thanks buddyyy.... can i edit the rows........... thanks in advance............









Related Pages:
excel parsing and print data in the form of table
excel parsing and print data in the form of table  my reqment is i have to parse the excel and i need to print the data in the table by using swing jtable or else ....can u give the solution please
exporting data to excel sheet - JDBC
exporting data to excel sheet  Sir i have already send request about... query in java swing program,i want to print the result about the query in excel...; Form(){ String data[][] = {{"",""}}; String col[] = {"Name
Print Form - Java Beginners
Print Form  Hello Sir I have Created Admission Form when user fills data and submit that data to access database,then when i Click on PRINT Button I want to get Print of that forms Contents,How I can Do it with JAVA SWING,plz
extract data from excel sheet to mysql
extract data from excel sheet to mysql  sir, i want to extract data from excel sheet and save the data in mysql5.0 database in the form of table
displaying data from ms excel in form.
displaying data from ms excel in form.  Hi all, I have a requirement as mentioned below: Requirement: I have stored some data in the ms excel... (for example). I need to display these data in a form. along with the actual picture
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web... table. So my question is ,I want so save this html format data in pdf/excel format... can save html table data in pdf/excel format.Your inputs are valuable to me
how to update values of a html form into an excel table using java servlets?
how to update values of a html form into an excel table using java servlets... be loaded into an excel table automatically. i have created a dsn for excel... are not loading into excel table. would you help me in solving this problem
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet? ... be loaded into an excel table automatically. i have created a dsn for excel table... are not loading into excel table. would you help me in solving this problem
save data in excel
save data in excel  hello sir, i'm new to this field i want to know can i save data in excel by html forms input,means if any one fill up form online then it is save offline in excel how can i do it can you give me solution sir
save data in excel
save data in excel  hello sir, i'm new to this field i want to know can i save data in excel by html forms input,means if any one fill up form online then it is save offline in excel how can i do it can you give me solution sir
insert excel value in to oracle data base
this Excel file then how excel data will mapp to oracle database table. My project...insert excel value in to oracle data base  Hi All I am using this code for saving excel value to oracle database table. code is working properly
Convert the excel sheet data into oracle table through java or jsp
Convert the excel sheet data into oracle table through java or jsp  Hi Friends, Let me help this issue i am phasing Convert the excel sheet data into oracle table through java or jsp
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i am designing a medical license website.i need to fillup a license form...)should automatically fill up in the form and on cliking print button it shoulg give
Retrieve Data into JTable and export it to Excel File
it into Vector which is then added to table. To export the table data to excel file, we... Java Retrieve Data into JTable and export it to Excel File... in the table and then export it to the Excel file. For this, we have created a table
How to import data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase??
How to import data from sql server table into an excel file by creating... data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase?? There is a table in sql server having
jsp data in excel - JSP-Servlet
in jsp using table. and getting this data from servlet which has query and this query data has come from beans and using beans i put it in excel jsp in table...jsp data in excel  i have create jsp page which has button
browse and submit the excel sheet into mysql as a table
browse and submit the excel sheet into mysql as a table  sir, i want to browse and after clicking a submit button, the data in the excel sheet should be stored in the mysql5.0 as a table
How to download web page table data, export the table records in an excel file and save
How to download web page table data, export the table records in an excel file and save  i have a web page(.jsp) which contains the table of 4 to 5 columns. i m displaying the table using in my jsp page. below this table i want
java parsing of data types
java parsing of data types  Why its not works? char ch; String s=* ch=Character.parseChar(s) program: char op; DataInputStream dis=new DataInputStream(System.in); System.out.print("Enter operator (+,-,*,/,%): "); op
Java and excel - JDBC
) ); } data.addElement( row ); } } catch(Exception e){} JTable table = new JTable(data... to a Jtable from where i can export to excel, i will like to format the column headers in excel using code. plz i nd help becos it is my project, as a serious student i
Hi how to transfer table data from html page to excel sheet by using javascript .
Hi how to transfer table data from html page to excel sheet by using javascript .  html page to excel sheet by using javascript and i dont want to transfer all rows in table, i want to hide some rows in excel sheet. Please send
Wrong parameter values while exporting data from jsp to excel
Wrong parameter values while exporting data from jsp to excel   This is a jsp report. When i export the report data to an excel, the parameter...(); out.println("Data is saved in excel file."); }catch ( Exception ex ){ } %>
Parsing Binary Data in PHP - PHP
Parsing Binary Data in PHP  Is there a better library for working with binary data in PHP
Problem facing in SAX Parsing - XML
the Batch to update the * Customer Data in the Database Table Customer...Problem facing in SAX Parsing  I have facing the issue in SAX Parsing... on the start of the document. on start of the * document reset the table
display:table export only data
display:table export only data  I am using display:table tag with attribute export="true". Using that I can export table data in excel. Here one of the column is in hyper link. But i need to export only data not html tag . Can
create folders and sub folders based on excel data
Current form this excel sheet how can i read the data line...create folders and sub folders based on excel data  Hi, i have a requirement that , read the data from excel sheet and based on that data i need
Insert data in Excel File from Database using JSP
Insert data in Excel File from Database  using JSP ... the data from database, create an excel file and data insert into newly... the search data in the excel file. Step 1: Create a web page ("SearchUser.jsp
excel
excel  how to save excel sheet data into the database using poi api...("Data is inserted"); stat.close(); con.close(); } catch(Exception e...+"')"); System.out.println("Data is inserted"); stat.close
Fetching data from excel file on other website and display in interactive graph form
Fetching data from excel file on other website and display in interactive graph... which have zip files and excel files and they get updated everyday, so how can i pull data data from those and generate graphs out of it? I really need it urgently
Printing data into Excel sheet - Java Beginners
Printing data into Excel sheet  Hi all i am writing one application where there is need to bring the data into "Excel Sheet" with proper format.My... database then showing it(data) to in "Excel Sheet" is it possible to do ? if yes
export data from database to excel sheet - JDBC
export data from database to excel sheet  I am facing a problem about exporting required data from database table to ms-excel sheet.i mean whenever I...("Data is saved in excel file."); rs.close(); connection.close(); } catch
how to display the data from excel to webpage
that reads the excel file and store data into table. <%@page import="java.io.*"%>...how to display the data from excel to webpage  Hi, I need help... search for the value 4024 in a excel file and to display the remaining values
Exception during parsing a parameter from the form in JSP
Exception during parsing a parameter from the form in JSP  Exception during parsing params from a form? I get parameters from a html form. I parse the integer one in the JSP file, but I get exception. Is there anyway I can get
SMS Parsing
; Message but it shows the querystring i.e sender name & message in the form
How to export data from database to excel sheet by using java swing in standalone project - Java Beginners
How to export data from database to excel sheet by using java swing... from u to solve my problem. my problem is i don know how to export data from database to excel sheet by using java swing in standalone project.I get solution from
Error in reading Excel data using jsp
Error in reading Excel data using jsp  ERROR while executing bellow...="org.apache.poi.hssf.usermodel.HSSFCell"%> <table border="1"> &lt;% short a=0; short b... import="org.apache.poi.hssf.usermodel.HSSFCell"%> <table border="1">
Create Excel Sheet Using JSP
;%@ page contentType="application/vnd.ms-excel" %> : Here, we insert the data into table. The data will display into tabular format in excel sheet. You can also... values into table of the excel sheet . In this example we use page directive
how to print pdf format
is a code that will store the database data into pdf table. We have used itext api...how to print pdf format  Hi every body iam doing school project iam using backend as oracle front end java .how to print student marks list
jsp excel code - JSP-Servlet
jsp excel code  hi how to store html form data into excel sheet by using jsp? and repeat this process continuously for entire sheet
insert excel sheet into mysql as a table
insert excel sheet into mysql as a table  sir, i want to import an excel sheet into mysql5.0 database as in the table format using tomcat 6.0 by jsp
Java Print the all components
JFrame implements ActionListener { Vector data; JTable table; JLabel banner...(td); np=ge-td; net=Double.toString(np); data = createData(); print=new...Java Print the all components  This is my code. Please tell me
Java swing: Export excel sheet data to JTable
Java swing: Export excel sheet data to JTable In this tutorial, you will learn how to read data from excel file and export it to JTable. In swing applications, sometimes, it is required to display the excel file data into the jtable
Export data in excel sheet via Browse and upload button into mysql database
Export data in excel sheet via Browse and upload button into mysql database  how to create a Browse & Upload Buttons and then save the information from it in mysql database's Table Am using struts2,hibernate for making
how to print JInternal frame component ?
how to print JInternal frame component ?  hello sir, i devalop a swing application .but problem is that how display report & print it. some data prefech from database & keep to jtable but how it is print with table
Jaret Table
(data and viewstate). Renderers and editors (including print rendering... Jaret Table         The jaret table is a custom drawn table for the SWT gui toolkit
Upload csv or .xlsx file from JSP form to Database Table using servlet
Upload csv or .xlsx file from JSP form to Database Table using servlet  dear sir, i need the Servlet code that reads the .xlsx or CSV excel file...; (contentType.indexOf("multipart/form-data") >= 0)) { DataInputStream
Employee form
Employee form  In employee form emp Id id after any data iserted is incremented for oher data insertion. insert, delete, update buttons when we cleak the select buttoun then the created table data iserted automaticaly
How to save data to excel with a 2.1 work sheet format without changing it?
How to save data to excel with a 2.1 work sheet format without changing... and save it to excel file then read it again .. the problem is , when data...","Address"}; DefaultTableModel model = new DefaultTableModel(data, col); table
Retrieve Data from the database and write into excel file
Retrieve Data from the database and write into excel file. In this section, we are going to retrieve data from the database and write into the excel file..., we have inserted the database table values in the excel sheet. Here

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.