Forum Discussion
kbhaskar
9 years agoOccasional 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
9 years agoCommunity 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;
}