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....

Google for "Andy Khan JExcel"

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...

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).

If u cudn't help me...datz fine...but mind ur wrds...

commented: I did help you, I simply didn't do it for you. -2

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.