write the result into excelsheet
package reader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class ReadExcel {
static String homeurl="http://192.168.5.19:79/Home.aspx";
public static void main( String [] args ) throws InterruptedException, IOException {
String fileName="E:\\excellogin.xls";;
//Read an Excel File and Store in a Vector
Vector dataHolder=readExcelFile(fileName);
//Print the data read
printToConsole(dataHolder);
// writeDataToExcelFile(fileName);
}
public static Vector readExcelFile(String fileName)
{
/** --Define a Vector
--Holds Vectors Of Cells
*/
Vector cellVectorHolder = new Vector();
List cellDataList = new ArrayList();
try{
/** Creating Input Stream**/
//InputStream myInput= ReadExcelFile.class.getResourceAsStream( fileName );
FileInputStream myInput = new FileInputStream(fileName);
/** Create a POIFSFileSystem object**/
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
/** Create a workbook using the File System**/
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
/** Get the first sheet from workbook**/
HSSFSheet mySheet = myWorkBook.getSheetAt(0);
/** We now need something to iterate through the cells.**/
Iterator rowIter = mySheet.rowIterator();
while(rowIter.hasNext()){
HSSFRow myRow = (HSSFRow) rowIter.next();
Iterator cellIter = myRow.cellIterator();
Vector cellStoreVector=new Vector();
while(cellIter.hasNext()){
HSSFCell myCell = (HSSFCell) cellIter.next();
cellStoreVector.addElement(myCell);
}
cellVectorHolder.addElement(cellStoreVector);
}
}catch (Exception e){e.printStackTrace(); }
return cellVectorHolder;
}
private static void printToConsole(List cellDataList) throws InterruptedException, IOException
{
for (int i = 1; i < cellDataList.size()+1; i++)
{
List cellTempList = (List) cellDataList.get(i);
//System.out.print(cellTempList + "\t");
final String sUrl = "http://192.168.5.19:79/ExATLogin.aspx?";
WebDriver d1 = new InternetExplorerDriver();
d1.get(sUrl);
HSSFCell hssfCell1 = (HSSFCell) cellTempList.get(0);
String stringCellValue1 = hssfCell1.toString();
System.out.print("UserName:" + stringCellValue1 + "\t");
d1.findElement(By.id("txt_UserName")).clear();
d1.findElement(By.id("txt_UserName")).sendKeys(stringCellValue1);
HSSFCell hssfCell = (HSSFCell) cellTempList.get(1);
String stringCellValue = hssfCell.toString();
System.out.print("Password:" + stringCellValue + "\t");
d1.findElement(By.id("txt_Password")).clear();
d1.findElement(By.id("txt_Password")).sendKeys(stringCellValue);
Thread.sleep(3000);
d1.findElement(By.name("btn_Login")).click();
String curUrl=d1.getCurrentUrl();
System.out.println("\n");
System.out.println(curUrl);
if(homeurl.equals(curUrl)){
System.out.println("Login successful");
}
else
System.out.println("Login not successful");
Thread.sleep(3000);
}
}
private static void write1() throws IOException{
FileInputStream file = new FileInputStream(new File("E:\\excellogin.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
Cell cell = null;
Cell cell1 = null;
Cell cell2 = null;
int row=1;
for(;row<5;row++){
cell=sheet.getRow(row).getCell(0);
cell1=sheet.getRow(row).getCell(1);
if(cell.equals("superadmin") && cell1.equals("Exdion")){
cell2 = sheet.getRow(row).getCell(2);
cell2.setCellValue(cell.getStringCellValue().concat("pass"));
}
else{
cell2 = sheet.getRow(row).getCell(2);
cell2.setCellValue(cell.getStringCellValue().concat("fail"));
}
}
file.close();
FileOutputStream outFile =new FileOutputStream(new File("E:\\excellogin.xls"));
workbook.write(outFile);
outFile.close();
}
}
my question is i want to wite the result in to the same excel file....... please help me. if username is superadmin and password is Exdion. then the status is pass othewise fail.
View Answers
Related Tutorials/Questions & Answers:
write the result into excelsheetwrite the
result into excelsheet package reader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import... the
result in to the same excel file....... please help me. if username is superadmin
Advertisements
how to upload a student time table excelsheet how to upload a student time table
excelsheet Hi good morning iam beginer iam doing project using struts frame work backend as 10g xe
front end as java .in my student module i have time table so how to upload
excelsheet display resultdisplay result i want a code that takes input from user through dropdown box and display the
result into table.all the values regarding the user input must be displayed. i am using mysql database
hi i want study
result problemresult problem sir,i have written program given below but that program is not giving proper output.pls help me
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;ADS_TO_REPLACE_1
class
ModuleNotFoundError: No module named 'result'ModuleNotFoundError: No module named '
result' Hi,
My Python... '
result'
How to remove the ModuleNotFoundError: No module named '
result'... to install padas library.
You can install
result python with following command
result after compilationresult after compilation public class MainCls
{
public static void main(String argv)
{
System.out.println("My text
write spreadsheetwrite spreadsheet what is the java code to
write a spreadsheet to database
write spreadsheetwrite spreadsheet what is the java code to
write a spreadsheet to database
write a programwrite a program
write a program add 2 no.s without use arithmetic,unary operaters in java
Result=Set - Java BeginnersResult=Set Hi Friend,
Can u tell how to get the count of records. in a select operation like
sqlstmt="SELECT * FROM search_log_tab WHERE...
result set, first move the pointer from first record to last record and get
Sort Result set Sort
Result set I build a connect for my page with the database and then read all rows and show it in a table, I want to change the view of my data to be sorted uppon a specific column when click on the column name, so what
result analysis issueresult analysis issue i have given 100 users in my thread group for http sampler.some threads r getting response and some threads r getting error response.the error response shown in view results tree listener is as shown below
WRITE AND TEST WRITE AND TEST
WRITE AND TEST PROGRAM TO ACCEPT A STRING?
1).WHICH STARTS WITH 'S' OR 's'
2).ENDS WITH "nd"
3) THE LENGTH OF THE STRING SHOULD BE 10 OR LESS
hide and show result in jsphide and show
result in jsp what codes do i have to change to make my
result display if only i enter the correct value?
suppose if i click search,then the
result will be display at the bottom.. if not.. only the header
ModuleNotFoundError: No module named 'result_py'ModuleNotFoundError: No module named '
result_py' Hi,
My Python... '
result_py'
How to remove the ModuleNotFoundError: No module named '
result... have to install padas library.
You can install
result_py python with following
Write to PDFWrite to PDF Hi,
Fairly new to this. I want to create a PDF file as a server call, with text/images sent to the app. Seeing that this will have to be a plugin, how do I go about making it a valid plugin for the server
how to write in xml? - XMLhow to
write in xml? can anybody give the code how to
write in xml file. i wan to
write inside the tag, so what i have to do?
Thanks... ...)
tFormer.setOutputProperty(OutputKeys.METHOD, "text");
//
Write the document to a file
Read WriteRead Write Hi;
How can I read certain line of say 10 text files and
write to one text file
Java Read Multiple Files and store the data into another text file
The given code reads all the text files of the directory
Result interface in Struts 2.2.1Result interface in Struts 2.2.1
Struts
Result interface is a public interface of package
com.opensymphony.xwork2. It extends Serializable interface. All the known
classes such as PlainTextResult, ServletRedirectResult,
Write a program in java...Write a program in java... Hi, friends
Please, can you help me?
Q1:
Write a program in java to simulate a calculator. Your program should take two... as a user wishes.
Print the
result up to two places of decimal.
Q2: Ask the user
Ajax Write
Ajax
Write
ajaxWrite is a web-based word processor that can read and
write Microsoft
Word and other standard document formats
Read full Description ADS_TO_REPLACE_1
select result from three tables using sql.select
result from three tables using sql. I want to get a
result from three tables. i dont how to
write the sql query. Please help me.
"I want to display Name,Username and Product_Name where Id=007"
table "register"
Name
select Query result display problemselect Query
result display problem Hi,
String SQL_QUERY ="from Cc";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Object[] row = (Object[]) it.next
Php Sql ResultPhp Sql
Result
This example illustrates how to display
result on the browser and how to
use the
result in the php application.
In this example we create a select query by using mysql_query method and
stored it in the
result variable
Result Set one to many mappingResult Set one to many mapping Suppose there are 5 tables in database named A,B,C,D and E.
A has one to many relationship with B,C,D and D has one...
Suppose
result contains single entry of One record for A, Two records for B
A Java Program That Prints Out Result Via PrinterA Java Program That Prints Out
Result Via Printer A Java Program That Prints Out
Result Through Printer Depending upon paper size , and print the calculated
result on printer and save
result as text file
JSP - Problem of displaying result at webpageJSP - Problem of displaying
result at webpage Can anyone please help to solve my problem below. My webpage has problem in displaying
result position. The
result should be display below my title. How do i solve it? Thank you so
how can i display a editable result of form?how can i display a editable
result of form? how can i display a editable
result of form? i know how to display form
result but the
result... to display form
result in same page i have alredy created a hidden div which
How to write a program count total pricesHow to
write a program count total prices Hi. all
I've got a assignment to
write a program that count total prices of 8 costumers.
class PriceCalculator{
public void method(double quantity)
{
double
result How to write in File in JavaHow to
write in File in Java Hi,
How to
write in File in Java. Please suggest and give example of this program.
thanks
Stream Result exampleStream
Result example
Stream
Result is very important for allowing users to downloading contents.
It is a custom
result type for sending raw data via... file name.
An Example of Stream
Result is given below
page.jspADS_TO_REPLACE_3