Need help in a appending output from a java pgm in an Existing Excel sheet

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 3
Reputation: rathinam86 is an unknown quantity at this point 
Solved Threads: 0
rathinam86 rathinam86 is offline Offline
Newbie Poster

Need help in a appending output from a java pgm in an Existing Excel sheet

 
0
  #1
Oct 6th, 2008
Hi

Cud anybody help me in sorting out this issue???...i have written a java code which fetches a text fils as an input & displays the output. Now i want to display the output in an existing Excel file in a desired format.

import java.io.*;

class hi
{
public static void main(String args[])
{
try
{
String inputFile,outputFile;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String days[] ={"= Mon","= Tue","= Wed","= Thu","= Fri","= Sat","= Sun"};
String preFix[] ={" ./"," ../","-b ","for "};
String postFix[] ={".trx",".trx"," -d",".trx"};
String jobInfo[][]=new String[100][100];
int preIndex,postIndex;
int flag=1;
int jobCount=0;
int ji=0,jsi=0;
System.out.println("Enter the Input File Name:");
inputFile = in.readLine();
//System.out.println("Enter the Prefix to find the files:");
//preFix = in.readLine();
//System.out.println("Enter the Postfix to find the files:");
//postFix = in.readLine();
System.out.println("Enter the Output File Name:");
outputFile = in.readLine();

FileReader filereader = new FileReader(inputFile);
BufferedReader bufferedreader = new BufferedReader(filereader);
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Java.txt", true)));



//FileWriter filewriter = new FileWriter(outputFile);
//BufferedWriter bufferedwriter = new BufferedWriter(filewriter);

while(true)
{
String line;
if((line = bufferedreader.readLine()) == null){

bufferedwriter.close();

break;
}
if(line.startsWith("= JOB"))
{
int index1= line.indexOf(":");
int index2= line.indexOf("#");
int index3= line.indexOf(".");
String stream=line.substring(index2+1,index3);
String job=line.substring(index3+1);
jobCount++;

jobInfo[ji][jsi]=job;

jobInfo[ji][jsi+1]=stream;

ji++;
bufferedwriter.write("JOB NO::"+jobCount);
bufferedwriter.newLine();
bufferedwriter.write("JOB STREAM ::"+stream);
bufferedwriter.newLine();
bufferedwriter.write("JOB NAME ::"+job);
bufferedwriter.newLine();
}// if

for(int dt=0;dt<days.length;dt++)
{
if(line.startsWith(days[dt]))
{
int index1= line.indexOf("=");
if(flag==1){
String time1 =line.substring(index1+2);
bufferedwriter.write("START TIME ::"+time1);
bufferedwriter.newLine();
flag=2;
}
else{
String time2 =line.substring(index1+2);
bufferedwriter.write("END TIME ::"+time2);
bufferedwriter.newLine();
bufferedwriter.newLine();
flag=1;
}
}// if
}//for

if(line.startsWith("= Exit"))
{
String status="Failure";
int index1= line.indexOf(":");
int stValue=Integer.parseInt((line.substring(index1+2)).trim());
if(stValue==0)
status="Success";
bufferedwriter.write("STATUS ::"+status);
bufferedwriter.newLine();

}// if

//if(line.startsWith(preFix))
//{


for(int x=0;x<preFix.length;x++)
{
preIndex= line.indexOf(preFix[x]);
if(preIndex!=-1)
{
postIndex=line.indexOf(postFix[x]);


/*System.out.println(preIndex);
System.out.println(postIndex);
System.out.println(preFix[x].length());*/
if(postIndex!=-1)
{
String files= line.substring(preIndex+preFix[x].length(),postIndex );
bufferedwriter.write(files);
bufferedwriter.newLine();
break;
}//postindex
}//preindex

}//for
//}


}//while



for(int i=0;i<ji;i++)
{
for(int j=0;j<2;j++)
{
/*System.out.println("jobInfo"+jobInfo[i][j]);*/
}
}

}//try
catch(Exception exception) {
/*System.out.println("jjjj"+exception);*/}

}//main

}//class

sample input:

= JOB : SAM-PIN-AU#APIN_BILL_FORM.APIN_FTP_PRINT_FORMATTER
= USER : pinPap Wave 2B pin user
= JCLFILE : vf_tws_bin_ftp_print_formatter_au.sh 172.19.3.72 vodafone.ftpuser vf1abx ${PIN_DATA_DIR}/apps/vf_au_fj_inv_print/OUTPUT ${PIN_DATA_DIR}/apps/vf_au_fj_inv_print/OUTPUT/sendqm ${PIN_DATA_DIR}/apps/vf_au_fj_inv_print/OUTPUT/sendqm
= Job Number: 23224
= Fri 08/22/08 07:37:18 EST

= Exit Status : 1
= System Time (Seconds) : 1 Elapsed Time (Minutes) : 0
= User Time (Seconds) : 0
= Fri 08/22/08 07:37:19 EST

Sample output:

JOB STREAM ::APIN_BILL_FORM
JOB NAME ::APIN_FTP_PRINT_FORMATTER
START TIME ::Fri 08/22/08 07:37:18 EST
STATUS ::Failure
END TIME ::Fri 08/22/08 07:37:19 EST

Now i want to display this output in a Excel sheet in the following format
Jobstream Jobname Status Starttime
APIN_BILL_FORM APIN_FTP_PRINT_FORMATTER Failure Fri 08/22/08 07:37:18 EST

Note : The Excel sheet already contains the field Jobstream,Jobname,status etc...we jus have to append the output in the desired cell...

Plz help me....
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Need help in a appending output from a java pgm in an Existing Excel sheet

 
0
  #2
Oct 6th, 2008
Google for "Andy Khan JExcel"
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: rathinam86 is an unknown quantity at this point 
Solved Threads: 0
rathinam86 rathinam86 is offline Offline
Newbie Poster

Re: Need help in a appending output from a java pgm in an Existing Excel sheet

 
0
  #3
Oct 6th, 2008
Hai...thanks for ur advice...but itz not abt dubugging...itz abt appending my code in such a way that it cud pop out the output in a Excel sheet...
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Need help in a appending output from a java pgm in an Existing Excel sheet

 
0
  #4
Oct 6th, 2008
Did you do what I told you to? That Google search is also not about debugging. If you would take the time to at last try what is suggested, you wouldn't come of as such a lazy "do-it-for-me" @sshole. That search will find Andy Khan's JExcel API which is an API for direct excel workbook creation/manipulation. So, now, how does that not answer your question (aside from not having done it for you).
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: rathinam86 is an unknown quantity at this point 
Solved Threads: 0
rathinam86 rathinam86 is offline Offline
Newbie Poster

Re: Need help in a appending output from a java pgm in an Existing Excel sheet

 
-1
  #5
Oct 6th, 2008
If u cudn't help me...datz fine...but mind ur wrds...
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Need help in a appending output from a java pgm in an Existing Excel sheet

 
0
  #6
Oct 6th, 2008
I did help you, but I am not going to do your (home)work for you. Do it yourself, I gave you a direct reference to a resource that will easily allow you to do so, if you motivate yourself enough to take advantage of it. But, as we both know, since it is not a simple copy-paste action, you won't be able to.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,678
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Need help in a appending output from a java pgm in an Existing Excel sheet

 
0
  #7
Oct 6th, 2008
http://www.andykhan.com/jexcelapi/tutorial.html

This basic tutorial should be enough to understand that the link supplied by masijade has what you need to start. Guess you didn't bother to give a closer look to the API and search what you need.

If you have written code using the API and got stuck somewhere then you might get a better response
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC