Forum Discussion

kbhaskar's avatar
kbhaskar
Occasional Contributor
8 years ago

how to read or write data from particular sheet in a workbook of excel

hey hi team 

 

can anyone suggest me how to get a particular value from particular sheet in an excel 

 

thanks in advance

3 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    You refer below links.

     

    For Write

    For Read

     

    Let me know if you want to achieve specific scenario with Excel

    • kbhaskar's avatar
      kbhaskar
      Occasional Contributor

      scenario

       

      for example there is workbook with three sheets orders,product id's and users, here i need to get or set data to sheet of product id's and i know activesheet but the product id's sheet is inactive.

       

      thanks for replying

      • shankar_r's avatar
        shankar_r
        Community Hero

        You can customize below code to get your scenario covered.

         

        function WriteData()
        {
                           
              var excelObject = Sys.OleObject("Excel.Application");
                    
              excelObject.Visible = false;
              excelObject.DisplayAlerts = false;
                    
              var excelWorkbookObj = excelObject.Workbooks.Open(strexcelFileName);
              var excelMainSheet = excelWorkbookObj.Sheets.Item("<Sheet Name want to Write>");
                          
              excelMainSheet.Range("A1").Value = "S.No";
              excelMainSheet.Range("B1").Value = "Module Name"
              excelWorkbookObj.Save();
              excelWorkbookObj.Close();
                          
              excelObject.Visible = true;
              excelObject.DisplayAlerts = true;
              excelObject.Quit()
              //CleaningUp
              excelObject = null;
              excelWorkbookObj = null;
              excelMainSheet = null; 
        }