5 Replies Latest reply on Dec 8, 2011 12:27 AM by yajiv_viki

    Please Help...!!  Is this to possible add data to write excel via java script

    yajiv_viki Level 2

      Team:

       

      Is this possible to write data to Excel using javascript.

       

      I have created ScriptUI Dialog window. but i can't able to store datas in Excel.

       

      I can add data column wise in excel( using writeln comment) but I can't able add data to Row wise.

       

      Please anyone help me to solve this problem...

       

      Thanks in Advance.

       

       

       

      -yajiv

       

       

       

      Source Window :

      Dialog.jpg

       

      and the outputs wants......

      save the excel name to the Batch ID..

       

      Output.jpg

        • 1. Re: Please Help...!!  Is this to possible add data to write excel via java script
          yajiv_viki Level 2

          Hi Everyone!

           

          I can add data column wise in excel( using writeln comment) but I can't able add data to Row wise.

           

          Please anyone help me to solve this problem...

           

          Thanks in Advance...

           

          -yajiv....

           

          Code :

          var myDoc = app.activeDocument;

          var myAllLinks = myDoc.allGraphics;

          var myLink=new Array()

          var mySeen = Object;

           

           

              var myLogFile = new File("~/Desktop/Link Files.xls");

              myLogFile.open("w", undefined, undefined)

              myLogFile.writeln("Link Name");

           

                for ( i = 1; i < myAllLinks.length; i++ )

                  {

                      var myLinkName = myAllLinks[i].itemLink.name;

                      var l=myLinkName.length;

                     var T=myLinkName.substring(l-4);

                      if (T==".tif"){

                          myLogFile.writeln(myAllLinks[i].itemLink.name);

                      }

                  }

          • 2. Re: Please Help...!!  Is this to possible add data to write excel via java script
            csm_phil Level 4

            Hi Yajiv,

             

            I have modifed your js code, just i make the change for column wise and row wise.

            Please try.

             

            var myDoc = app.activeDocument;
            var myAllLinks = myDoc.allGraphics;
            var myLink=new Array()
            var mySeen = Object;
            var myLogFile = new File("~/Desktop/Link Files.xls");
            myLogFile.open("w", undefined, undefined)
            myLogFile.writeln("Link Name");
            var arr=[];
            for ( i = 0; i < myAllLinks.length; i++ ){ 
                 var myLinkName = myAllLinks[i].itemLink.name;
                 var l=myLinkName.length;
                 var T=myLinkName.substring(l-4);
                 if (T==".tif"){
                      arr.push(myAllLinks[i].itemLink.name);
                      }
                 }
            
            //_______ which thing you need just comment another thing.
            // this is row wise adding
            
            //myLogFile.writeln(arr.join("\t"));
            // this is column wise adding
            myLogFile.writeln(arr.join("\r"));
            

             

             

            thx

            csm_phil

            1 person found this helpful
            • 3. Re: Please Help...!!  Is this to possible add data to write excel via java script
              yajiv_viki Level 2

              Hi csm_phil,

               

              Thank you so much for your reply.

               

              its works..!!!

               

              I have use above your code....

               

              myLogFile.writeln(arr.join("\t"));

              Thanks lot.

               

               

              Is this possible to get specific cell value and update that value..?

               

              For Ex:

               

              get C11 and update C11.

               

               

              -yajiv

              • 4. Re: Please Help...!!  Is this to possible add data to write excel via java script
                csm_phil Level 4

                Hi Yajiv,

                 

                I am not sure to change the value, but we can read the value of the specified column.

                 

                Please try the below js code.

                 

                 

                var myDoc = app.activeDocument;
                var myAllLinks = myDoc.allGraphics;
                var myLink=new Array()
                var mySeen = Object;
                var myLogFile = new File("~/Desktop/Link Files.xls");
                myLogFile.open("w", undefined, undefined)
                myLogFile.writeln("Link Name");
                var arr=[];
                for ( i = 0; i < myAllLinks.length; i++ ){ 
                     var myLinkName = myAllLinks[i].itemLink.name;
                     var l=myLinkName.length;
                     var T=myLinkName.substring(l-5);
                     if (T==".jpeg"){
                          arr.push(myAllLinks[i].itemLink.name);
                          }
                     }
                myLogFile.writeln(arr.join("\t"));
                
                if (myLogFile != null) {
                     myLogFile.open("r") ; 
                     var myExcel = myLogFile.read(); 
                     myLogFile.close();
                     myExcel = myExcel.split("\t");
                     }
                
                //below line alert the first column contents 
                alert(myExcel[0]);
                
                
                //below line alert the second column contents 
                alert(myExcel[1]);
                

                 

                 

                thx

                csm_phil

                1 person found this helpful